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 ...