Armand Niculescu

Armand is a 32 year old designer and programmer employed with Media Division. He has 15 years experience with programming, specializing in scripting languages such as Actionscript, Javascript and PHP. He also does design and photography.

7 responses to “Converting rootless XmlReader to XmlDocument in .NET”

  1. J

    To quote you “There’s no straightforward way to convert a XmlReader to a XmlDocument – most of the code samples I’ve seen simply read sequentially through the XmlReader, appending data to a string. Obviously this is inneficient.”.

    Isn’t much easier to use the “Load” method on the XmlDocument class? One of the 4 overloads accept an XmlReader as aparameter.

  2. Armand Niculescu

    There was some poor wording on my part.
    It should have read “There’s no straightforward way to convert a XmlReader without a root node to a XmlDocument”.

  3. sam sinfield

    This looked to be exactly what I needed for converting data from an sql server db to a xmldoc. Unfortunately, I’m using .net 1.1 and don’t have the option to upgrade and this has only been added in .net 2.0. Is there any other, elegant way of doing this in 1.1 without having to sequentially read through the XmlReader

  4. Armand Niculescu

    Sam, if you’re using MSSQL 2005, you can specify the root node in the query itself, like this:
    ...FOR XML AUTO, ROOT('doc')

    I don’t know of any other way.

  5. Wayne Scholar

    Great Article. We’re using Flex and needed this badly!

    Thanks!

    Wayne

  6. Sebastian

    Great Article. I wish I had find it sooner.

    Here is another way of doing the same with an XMLDocumentFragment.
    It works, but it could use some cleanup, specially around the ugly way I’m parsing each node.

    Just go to my blog look at my post.

    Thanks! Sebastian

  7. xmlreader - StartTags.com

    [...] @ StartTags Converting rootless XmlReader to XmlDocument in .NETHow to convert an XmlReader that lack the root node into a XmlDocumentXML Reader Flash panel | [...]

Leave a Reply