﻿<?xml version="1.0" encoding="UTF-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Select Nodes with XPathNavigator</Title>
      <Author>Microsoft Corporation</Author>
      <Description>Creates an iterator to walkthrough selected nodes.</Description>
      <Shortcut>xmlNavNodes</Shortcut>
    </Header>
    <Snippet>
      <References>
        <Reference>
          <Assembly>System.XML.dll</Assembly>
          <Url />
        </Reference>
      </References>
      <Imports>
        <Import>
          <Namespace>System.Xml.XPath</Namespace>
        </Import>
      </Imports>
      <Declarations>
        <Literal>
          <ID>FileName</ID>
          <Type>String</Type>
          <ToolTip>Replace this with your string.</ToolTip>
          <Default>"data.xml"</Default>
        </Literal>
        <Literal>
          <ID>NodePath</ID>
          <Type>String</Type>
          <ToolTip>Replace this with your string.</ToolTip>
          <Default>"parent/child"</Default>
        </Literal>
      </Declarations>
      <Code Language="VB" Kind="method body"><![CDATA[Dim pathExpr As XPathExpression
Dim document As New XPathDocument($FileName$)

' Create an XPathNavigator.
Dim pathNavigator As XPathNavigator = document.CreateNavigator()

' Get the Book elements.
Dim selectExpr As String = $NodePath$

' Ensure we are at the root node.
pathNavigator.MoveToRoot()

pathExpr = pathNavigator.Compile(selectExpr)

' Create an XPathNodeIterator to walk over the selected nodes.
Dim nodeIterator As XPathNodeIterator = pathNavigator.Select(pathExpr)
While nodeIterator.MoveNext

End While]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>