Language
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The XmlDocument exposes namespace declarations and xmlns attributes as part of the document object model. These are stored in the XmlDocument, so when you save the document, it can preserve the location of those attributes. Changing these attributes has no effect on the Name, NamespaceURI, and Prefix properties of other nodes already in the tree. For example, if you load the following document, then the test element has NamespaceURI 123.
<test xmlns="123"/>
If you remove the xmlns attribute as follows, then the test element still has the NamespaceURI of 123.
doc.documentElement.RemoveAttribute("xmlns")
doc.documentElement.RemoveAttribute("xmlns");
Likewise, if you add a different xmlns attribute to the doc element as follows, then the test element still has NamespaceURI 123.
doc.documentElement.SetAttribute("xmlns","456")
doc.documentElement.SetAttribute("xmlns","456");
Therefore, changing xmlns attributes will have no effect until you save and reload the XmlDocument object.