O'Reilly logo

Microsoft® .NET Compact Framework Kick Start by Ronnie Yates, Erik Rubin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Loading the XML DOM

If you want to load existing XML into an XmlDocument, there are two very similar methods that can be used: Load and LoadXml. The Load method can load an XML document from a Stream, TextReader, or XmlReader. The LoadXml method can load the XML only from a string. Listing 11.2 shows how to use both Load methods as well as create an XmlDocument.

Listing 11.2.
 C# // Load the document from a stream XmlDocument doc = new XmlDocument(); doc.Load(new FileReader("bogus.xml", FileMode.Open)); // Load the document from a TextReader doc = new XmlDocument(); doc.Load(new StreamReader("bogus.xml")); // Load the document from a XmlReader doc = new XmlDocument(); doc.Load(new XmlTextReader("bogus.xml"); // Load the document for an XML string ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required