Posted By: FluffyDevilBunny | Nov 6th, 2006 @ 9:00 AM
page 1 of 1
Comments: 3 | Views: 4378
FluffyDevilBunny
FluffyDevilBunny
GO GO GADGET COMPILER!
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?

Thanks much

-FDB
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?

Thanks much

-FDB


I vaguely remember a similar situation, my solution lied somewhere in the XmlNamespaceManager class.

Sorry, that's about all I can recall at the moment.
blowdart
blowdart
Peek-a-boo
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);


littleguru
littleguru
<3 Seattle
I did it in this example: http://channel9.msdn.com/ShowPost.aspx?PostID=249751. I needed to register namespaces for the RSS feed. This could help you Smiley
page 1 of 1
Comments: 3 | Views: 4378
Microsoft Communities