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.

First, decoupl<strong>in</strong>g data conta<strong>in</strong>ers from navigators, and navigators from iterators,represents a good barga<strong>in</strong> from the software standpo<strong>in</strong>t. The ultimate reason <strong>for</strong>keep<strong>in</strong>g the navigation and the iteration API dist<strong>in</strong>ct, however, is that <strong>in</strong> this way theresults of any XPath query can be easily accessed and processed from differentprogramm<strong>in</strong>g environments—<strong>XML</strong> DOM, XPath, and, last but not least, XSLT.The XPathNodeIterator ClassThe XPathNodeIterator class has no public constructor and can be created only by theparent navigator object. The iterator provides <strong>for</strong>ward-only access to the nodesselected by XPath query. Callers use the iterator's methods and properties to access allthe nodes <strong>in</strong>cluded <strong>in</strong> the node-set. Figure 6-7 illustrates the relationship betweencallers, navigators, and iterators. A caller passes an XPath expression. The navigatorexecutes the command and gets a node-set. The caller then receives an iterator objectto access the members of the node-set. Current, Count, and MoveNext are the keymembers of the iterator's programm<strong>in</strong>g <strong>in</strong>terface.Figure 6-7: The relationship between callers, navigators, and iterators.Properties of the Iterator ObjectTable 6-10 summarizes the properties exposed by the XPathNodeIterator class.Table 6-10: Properties of the XPathNodeIterator ClassPropertyCountCurrentDescriptionReturns the number of elements <strong>in</strong> the node-set. Thisvalue refers to the top-level nodes and does not considerchild nodes.Returns a reference to a navigator object rooted <strong>in</strong> the233

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

Saved successfully!

Ooh no, something went wrong!