YZlat
asked on
XmlDocument and VB.NET
I have an XmlDocument with a root node
<root>
</root>
I want to add the following attributes to the root node:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
and
xsi:noNamespaceSchemaLocat ion="../XS D/schema1. xsd"
so that my document look like this:
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocat ion="../XS D/schema1. xsd".
</root>
here is my code to accomplish that:
''add attributes to the root node
root.SetAttribute("xmlns:x si", "http://www.w3.org/2001/XMLSchema-instance")
root.SetAttribute("xsi:noN amespaceSc hemaLocati on", "../XSD/schema1.xsd")
It works but for some reason in the second attribute it omits the "xsi:" prefix.
So instead of
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocat ion="../XS D/schema1. xsd".
</root>
I get
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" noNamespaceSchemaLocation= "../XSD/sc hema1.xsd" .
</root>
Why is it happening and how can I fix it?
<root>
</root>
I want to add the following attributes to the root node:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
and
xsi:noNamespaceSchemaLocat
so that my document look like this:
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocat
</root>
here is my code to accomplish that:
''add attributes to the root node
root.SetAttribute("xmlns:x
root.SetAttribute("xsi:noN
It works but for some reason in the second attribute it omits the "xsi:" prefix.
So instead of
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocat
</root>
I get
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" noNamespaceSchemaLocation=
</root>
Why is it happening and how can I fix it?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks a lot Carl!