FluffyDevilBunny wrote:
Hi Guys,
I am using the XMLDocument class behind the scenes from an object. Consumers of the object can inherit from my class and add extended properties, which then become part of the XML Document.
I need to register thier namespace at the root level of the document, but I don't see a way to do that. The first time it is used, the xmlns is registered on that node.
How can I pre-register a ns on the root node?
Create the right attributes on the root node?
XmlDocument xmlDoc;
.....
XmlAttributeCollection documentAttributes = xmlDoc.Attributes;
XmlNode namespaceNode = xmlDoc.CreateNode(XmlNodeType.Attribute, "xmlns", "namespacePrefix", "http://www.w3.org/2000/xmlns/");
namespaceNode.Value = "namespaceURL";
documentAttributes.Append((XmlAttribute)namespaceNode);