Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - xmlns attribute woes [Thread Next] Re: xmlns attribute woesTo: NULL Date: 3/4/2009 2:42:00 AM Ah, never mind, I found it. Amazing what the right search phrase will
do... ;)
For reference for anyone else with the same problem, search this group
using the phrase "empty xmlns". Also, using createElement and then
setting the attribute won't work (it just writes the same xmlns for
each element), instead use createNode(NODE_ELEMENT, "elementname",
parentelement.namespaceURI).
On Mar 4, 11:42=A0am, rea...@gmail.com wrote:
> I want to generate the following using VB6 / XML DOM:
>
> <person xmlns=3D"urn:person-schema">
> =A0 <personal>
> =A0 =A0 ...
> =A0 </personal>
> </person>
>
> Naively, I tried the following code:
>
> Dim x As DOMDocument40: Set x =3D New DOMDocument40
>
> Dim p As IXMLDOMElement: Set p =3D xmlFile.createElement("person")
> p.setAttribute "xmlns", "urn:person-schema"
> x.appendChild p
>
> Dim q As IXMLDOMElement: Set q =3D xmlFile.createElement("personal")
> p.appendChild q
>
> But x.xml returns:
>
> <person xmlns=3D"urn:person-schema">
> =A0 <personal xmlns=3D"">
> =A0 =A0 ...
> =A0 </personal>
> </person>
>
> The problem is the empty xmlns attribute on the personal element. =A0I
> tried q.removeAttribute "xmlns", but it doesn't remove it. =A0Based on
> some code samples I saw, I tried the following instead of
> setAttribute, but it doesn't generate the attribute I want.
>
> Dim xsd As DOMDocument40: Set xsd =3D New DOMDocument40
> xsd.async =3D False
> xsd.Load App.Path & "\xsd\person-schema.xsd"
>
> Dim cache As XMLSchemaCache40: Set cache =3D New XMLSchemaCache40
> cache.Add "urn:person-schema", xsd
>
> Set x.schemas =3D cache
>
> I haven't been able to find any relevant info via MSDN / Google. =A0Any
> ideas what I'm doing wrong?
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
