Monday, September 12, 2005

Using XmlTextReader to read XML from Text Variables

For those who have used the .NET XMLTextReader - they will be well aware that is lets you load the xml file and then read through the nodes and attributes. Recently I faced a painfull situation when my XML was in a plain simple sting variable instead of a file. I though of loading it into a Stream and passing it to the XMLTextReader and a 100 other crappy solutions till this one looked most elegant and worked!

ds.ReadXml(new XmlTextReader(new StringReader(myStringWithXml)));
[Where ds is the instance of my XMLTextReader]

This User Group provides more information

0 Comments:

Post a Comment

<< Home