Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: xmlns attribute woes xmlns attribute woesTo: NULL Date: 3/4/2009 1:42:00 AM I want to generate the following using VB6 / XML DOM:
<person xmlns="urn:person-schema">
<personal>
...
</personal>
</person>
Naively, I tried the following code:
Dim x As DOMDocument40: Set x = New DOMDocument40
Dim p As IXMLDOMElement: Set p = xmlFile.createElement("person")
p.setAttribute "xmlns", "urn:person-schema"
x.appendChild p
Dim q As IXMLDOMElement: Set q = xmlFile.createElement("personal")
p.appendChild q
But x.xml returns:
<person xmlns="urn:person-schema">
<personal xmlns="">
...
</personal>
</person>
The problem is the empty xmlns attribute on the personal element. I
tried q.removeAttribute "xmlns", but it doesn't remove it. Based 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 = New DOMDocument40
xsd.async = False
xsd.Load App.Path & "\xsd\person-schema.xsd"
Dim cache As XMLSchemaCache40: Set cache = New XMLSchemaCache40
cache.Add "urn:person-schema", xsd
Set x.schemas = cache
I haven't been able to find any relevant info via MSDN / Google. Any
ideas what I'm doing wrong?
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
