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 XML Data into an XmlTextReader

The first thing to do when parsing an XML document with an XmlTextReader is to load the stream into the reader. To do this, you simply need to create an instance of the XmlTextReader and tell it where it can find the document. The .NET Compact Framework provides several overloaded constructors for loading an XmlTextReader from different sources.

Loading an XML Stream from the Local File System

The easiest way to create an instance of the XmlTextReader is to call the constructor that takes a string representing the URI to where the XML document can be found, as shown in Listing 10.1.

Listing 10.1.
 C# XmlTextReader reader = new XmlTextReader("filename.xml"); VB Dim reader As New XmlTextReader("filename.xml") ...

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