13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The XmlReader ClassThe XmlReader class def<strong>in</strong>es methods that enable you to pull data from an <strong>XML</strong> sourceand to skip unwanted nodes. Bear <strong>in</strong> m<strong>in</strong>d that each and every element <strong>in</strong> an <strong>XML</strong>stream is considered a node, mean<strong>in</strong>g that node is a rather generic concept thatapplies to subtree roots as well as to attributes, process<strong>in</strong>g <strong>in</strong>structions, entities,comments, and pla<strong>in</strong> text.The XmlReader class <strong>in</strong>cludes methods <strong>for</strong> read<strong>in</strong>g <strong>XML</strong> content from an entire text file,return<strong>in</strong>g the depth of the current <strong>XML</strong> node's subtree, and determ<strong>in</strong><strong>in</strong>g whether thecontents of a given element is empty. You can also fairly easily read and navigateattributes and skip over elements and their contents. Valuable <strong>in</strong><strong>for</strong>mation such as thename and the contents of the current node is also returned via ad hoc properties.Base Properties of <strong>XML</strong> ReadersTable 2-1 lists the public properties exposed by the XmlReader class. Notice that thevalues these properties conta<strong>in</strong> depend on the actual reader class you are us<strong>in</strong>g <strong>in</strong> yourcode. The description of each property refers to the property's <strong>in</strong>tended goal, but thisdescription might not entirely reflect the actual role of the property <strong>in</strong> a derived readerclass.Table 2-1: Public Properties of the XmlReader ClassPropertyAttributeCountBaseURICanResolveEntityDepthEOFHasAttributesHasValueIsDefaultIsEmptyElementItemLocalNameNameNamespaceURINameTableNodeTypeDescriptionGets the number of attributes on the current node.Gets the base URI of the current node.Gets a value <strong>in</strong>dicat<strong>in</strong>g whether the reader can resolveentities.Gets the depth of the current node <strong>in</strong> the <strong>XML</strong>document.Indicates whether the reader has reached the end ofthe stream.Indicates whether the current node has any attributes.Indicates whether the current node can have a value.Indicates whether the current node is an attribute thatorig<strong>in</strong>ated from the default value def<strong>in</strong>ed <strong>in</strong> thedocument type def<strong>in</strong>ition (DTD) or schema.Indicates whether the current node is an emptyelement with no attributes or value.Indexer property that returns the value of the specifiedattribute.Gets the name of the current node with any prefixremoved.Gets the fully qualified name of the current node.Gets the namespace URI of the current node. Appliesto Element and Attribute nodes only.Gets the name table object associated with the reader.(More on name table objects later.)Gets the type of the current node.22

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!