Tech Off Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

XmlDocument Question

Back to Forum: Tech Off
  • User profile image
    FluffyDevil​Bunny

    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

  • User profile image
    phreaks

    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.

  • User profile image
    blowdart

    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);


  • User profile image
    littleguru

    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

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.