April 2002
Intermediate to advanced
1024 pages
23h 26m
English
The model that the .NET Framework uses to read and parse XML files is somewhat of a mix between the traditional COM approach and the SAX approach. Listing B.69 shows how to read in and process an XML file (xmlread.cs). Two sample XML files, booklist.xml and number-list.xml, have also been included.
public class ReadXmlFile { public static void Main(string [] args) { string document = "booklist.xml"; ReadXmlFile readXml = new ReadXmlFile(); if ( args.Length > 0 ) { foreach(string arg in args) readXml.Process(arg); } else readXml.Process(document); } public void Process(String document) { XmlTextReader reader = null; try { // Load the file with an XmlTextReader. Console.WriteLine ("Reading file {0} ... |
Read now
Unlock full access