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

Reading XML Attributes

Now that you know how to move downward through a document, visiting nodes along the way, let's investigate moving horizontally through the reader, investigating attributes on elements. Since attributes appear adjacent to an element's start tag, I refer to moving through attributes as moving “horizontally” through the XML document.

Reading Attributes without Moving the Reader

One effective way to move through the attributes of an element is to set up a loop and simply read each one sequentially. The XmlTextReader provides properties and accessors to do just this. Listing 10.11 defines a method that searches the current element's attribute list looking for a specified value. The index of the attribute is returned if a matching ...

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