August 2003
Beginner to intermediate
600 pages
12h 57m
English
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.
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 ... |
Read now
Unlock full access