Thursday, July 3, 2008

Read in a String of XML to an XPathDocument in ASP.NET

Had a string representation of an XML file today that needed to be read into an XPathDocument object.

// results was the string XML file representation
StringReader sReader = new StringReader(results);
XmlReader xReader = new XmlTextReader(sReader);
XPathDocument myXpathDocument = new XPathDocument(xReader);