home *** CD-ROM | disk | FTP | other *** search
/ ftp.tcs3.com / ftp.tcs3.com.tar / ftp.tcs3.com / DRIVERS / Audio / Office2010 / InfoPath.en-us / InfLR.cab / FL_SelectNnodeswithXpathNavigator_snippet_142740_ENU____.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Extensible Markup Language  |  2008-09-17  |  2KB  |  57 lines

  1. ∩╗┐<?xml version="1.0" encoding="UTF-8"?>
  2. <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  3.   <CodeSnippet Format="1.0.0">
  4.     <Header>
  5.       <Title>Select Nodes with XPathNavigator</Title>
  6.       <Author>Microsoft Corporation</Author>
  7.       <Description>Creates an iterator to walkthrough selected nodes.</Description>
  8.       <Shortcut>xmlNavNodes</Shortcut>
  9.     </Header>
  10.     <Snippet>
  11.       <References>
  12.         <Reference>
  13.           <Assembly>System.XML.dll</Assembly>
  14.           <Url />
  15.         </Reference>
  16.       </References>
  17.       <Imports>
  18.         <Import>
  19.           <Namespace>System.Xml.XPath</Namespace>
  20.         </Import>
  21.       </Imports>
  22.       <Declarations>
  23.         <Literal>
  24.           <ID>FileName</ID>
  25.           <Type>String</Type>
  26.           <ToolTip>Replace this with your string.</ToolTip>
  27.           <Default>"data.xml"</Default>
  28.         </Literal>
  29.         <Literal>
  30.           <ID>NodePath</ID>
  31.           <Type>String</Type>
  32.           <ToolTip>Replace this with your string.</ToolTip>
  33.           <Default>"parent/child"</Default>
  34.         </Literal>
  35.       </Declarations>
  36.       <Code Language="VB" Kind="method body"><![CDATA[Dim pathExpr As XPathExpression
  37. Dim document As New XPathDocument($FileName$)
  38.  
  39. ' Create an XPathNavigator.
  40. Dim pathNavigator As XPathNavigator = document.CreateNavigator()
  41.  
  42. ' Get the Book elements.
  43. Dim selectExpr As String = $NodePath$
  44.  
  45. ' Ensure we are at the root node.
  46. pathNavigator.MoveToRoot()
  47.  
  48. pathExpr = pathNavigator.Compile(selectExpr)
  49.  
  50. ' Create an XPathNodeIterator to walk over the selected nodes.
  51. Dim nodeIterator As XPathNodeIterator = pathNavigator.Select(pathExpr)
  52. While nodeIterator.MoveNext
  53.  
  54. End While]]></Code>
  55.     </Snippet>
  56.   </CodeSnippet>
  57. </CodeSnippets>