Sunday, July 18, 2010

Creating XMLDocument from Program Embedded String in C#

Problem:

You want to quickly create a simple XML document without needing to write data to a file.

Solution:

Use StringReader class and feed that into the Load() function.

 Example Code:
XmlDocument doc = new XmlDocument();
doc.Load(new StringReader("<myNode>Hello</myNode>"));


Update: Well, that was doing too much, Load(string) would have worked just as well.
Post a Comment