<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net_Tutorial%2FXML%2FXML_Tree</id>
		<title>VB.Net Tutorial/XML/XML Tree - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net_Tutorial%2FXML%2FXML_Tree"/>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/XML/XML_Tree&amp;action=history"/>
		<updated>2026-04-05T11:59:01Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net_Tutorial/XML/XML_Tree&amp;diff=3055&amp;oldid=prev</id>
		<title> в 16:40, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/XML/XML_Tree&amp;diff=3055&amp;oldid=prev"/>
				<updated>2010-05-26T16:40:30Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 16:40, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net_Tutorial/XML/XML_Tree&amp;diff=3056&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/XML/XML_Tree&amp;diff=3056&amp;oldid=prev"/>
				<updated>2010-05-26T12:54:08Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Load XML document to a TreeView==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&amp;quot;Visual Basic.NET How to Program, Second Edition&lt;br /&gt;
&amp;quot;by Harvey M. Deitel (Author), Paul J. Deitel (Author), Tem R. Nieto (Author)&lt;br /&gt;
&amp;quot; Publisher: Prentice Hall; 2 edition (December 11, 2001)&lt;br /&gt;
&amp;quot; Language: English&lt;br /&gt;
&amp;quot; ISBN-10: 0130293636&lt;br /&gt;
&amp;quot; ISBN-13: 978-0130293633&lt;br /&gt;
&lt;br /&gt;
Imports System.Xml&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
Imports System.CodeDom.rupiler &amp;quot; contains TempFileCollection&lt;br /&gt;
&lt;br /&gt;
public class LoadXMLTreeView&lt;br /&gt;
   public Shared Sub Main&lt;br /&gt;
        Application.Run(New FrmXmlDom)&lt;br /&gt;
   End Sub&lt;br /&gt;
End class&lt;br /&gt;
Public Class FrmXmlDom&lt;br /&gt;
   Inherits Form&lt;br /&gt;
   &amp;quot; TextBox and TreeView for displaying data&lt;br /&gt;
   Friend WithEvents txtConsole As TextBox&lt;br /&gt;
   Friend WithEvents treXml As TreeView&lt;br /&gt;
   &amp;quot; Buttons for building, printing and reseting DOM tree&lt;br /&gt;
   Friend WithEvents cmdBuild As Button&lt;br /&gt;
   Friend WithEvents cmdPrint As Button&lt;br /&gt;
   Friend WithEvents cmdReset As Button&lt;br /&gt;
   Private source As XmlDocument &amp;quot; reference to &amp;quot;XML document&amp;quot;&lt;br /&gt;
   &amp;quot; reference copy of source&amp;quot;s &amp;quot;XML document&amp;quot;&lt;br /&gt;
   Private copy As XmlDocument&lt;br /&gt;
   Private tree As TreeNode &amp;quot; TreeNode reference&lt;br /&gt;
   Public Sub New()&lt;br /&gt;
      MyBase.New()&lt;br /&gt;
      &amp;quot; This call is required by the Windows Form Designer.&lt;br /&gt;
      InitializeComponent()&lt;br /&gt;
      &amp;quot; Add any initialization after the &lt;br /&gt;
      &amp;quot; InitializeComponent() call&lt;br /&gt;
      &amp;quot; create XmlDocument and load letter.xml&lt;br /&gt;
      source = New XmlDocument()&lt;br /&gt;
      source.Load(&amp;quot;YourFile.xml&amp;quot;)&lt;br /&gt;
      &amp;quot; initialize references to Nothing&lt;br /&gt;
      copy = Nothing&lt;br /&gt;
      tree = Nothing&lt;br /&gt;
   End Sub &amp;quot; New&lt;br /&gt;
#Region &amp;quot; Windows Form Designer generated code &amp;quot;&lt;br /&gt;
   &amp;quot;Form overrides dispose to clean up the component list.&lt;br /&gt;
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)&lt;br /&gt;
      If disposing Then&lt;br /&gt;
         If Not (components Is Nothing) Then&lt;br /&gt;
            components.Dispose()&lt;br /&gt;
         End If&lt;br /&gt;
      End If&lt;br /&gt;
      MyBase.Dispose(disposing)&lt;br /&gt;
   End Sub&lt;br /&gt;
   &amp;quot;Required by the Windows Form Designer&lt;br /&gt;
   Private components As System.ruponentModel.Container&lt;br /&gt;
   &amp;quot;NOTE: The following procedure is required by the Windows Form Designer&lt;br /&gt;
   &amp;quot;It can be modified using the Windows Form Designer.  &lt;br /&gt;
   &amp;quot;Do not modify it using the code editor.&lt;br /&gt;
   &amp;lt;System.Diagnostics.DebuggerStepThrough()&amp;gt; Private Sub InitializeComponent()&lt;br /&gt;
      Me.treXml = New System.Windows.Forms.TreeView()&lt;br /&gt;
      Me.cmdBuild = New System.Windows.Forms.Button()&lt;br /&gt;
      Me.txtConsole = New System.Windows.Forms.TextBox()&lt;br /&gt;
      Me.cmdPrint = New System.Windows.Forms.Button()&lt;br /&gt;
      Me.cmdReset = New System.Windows.Forms.Button()&lt;br /&gt;
      Me.SuspendLayout()&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;treXml&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.treXml.ImageIndex = -1&lt;br /&gt;
      Me.treXml.Location = New System.Drawing.Point(8, 40)&lt;br /&gt;
      Me.treXml.Name = &amp;quot;treXml&amp;quot;&lt;br /&gt;
      Me.treXml.SelectedImageIndex = -1&lt;br /&gt;
      Me.treXml.Size = New System.Drawing.Size(344, 192)&lt;br /&gt;
      Me.treXml.TabIndex = 3&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;cmdBuild&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.cmdBuild.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))&lt;br /&gt;
      Me.cmdBuild.Location = New System.Drawing.Point(8, 8)&lt;br /&gt;
      Me.cmdBuild.Name = &amp;quot;cmdBuild&amp;quot;&lt;br /&gt;
      Me.cmdBuild.Size = New System.Drawing.Size(104, 23)&lt;br /&gt;
      Me.cmdBuild.TabIndex = 0&lt;br /&gt;
      Me.cmdBuild.Text = &amp;quot;Build&amp;quot;&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;txtConsole&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.txtConsole.Location = New System.Drawing.Point(8, 240)&lt;br /&gt;
      Me.txtConsole.Multiline = True&lt;br /&gt;
      Me.txtConsole.Name = &amp;quot;txtConsole&amp;quot;&lt;br /&gt;
      Me.txtConsole.ScrollBars = System.Windows.Forms.ScrollBars.Vertical&lt;br /&gt;
      Me.txtConsole.Size = New System.Drawing.Size(344, 96)&lt;br /&gt;
      Me.txtConsole.TabIndex = 4&lt;br /&gt;
      Me.txtConsole.Text = &amp;quot;&amp;quot;&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;cmdPrint&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.cmdPrint.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))&lt;br /&gt;
      Me.cmdPrint.Location = New System.Drawing.Point(128, 8)&lt;br /&gt;
      Me.cmdPrint.Name = &amp;quot;cmdPrint&amp;quot;&lt;br /&gt;
      Me.cmdPrint.Size = New System.Drawing.Size(104, 23)&lt;br /&gt;
      Me.cmdPrint.TabIndex = 1&lt;br /&gt;
      Me.cmdPrint.Text = &amp;quot;Print&amp;quot;&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;cmdReset&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.cmdReset.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))&lt;br /&gt;
      Me.cmdReset.Location = New System.Drawing.Point(248, 8)&lt;br /&gt;
      Me.cmdReset.Name = &amp;quot;cmdReset&amp;quot;&lt;br /&gt;
      Me.cmdReset.Size = New System.Drawing.Size(104, 23)&lt;br /&gt;
      Me.cmdReset.TabIndex = 2&lt;br /&gt;
      Me.cmdReset.Text = &amp;quot;Reset&amp;quot;&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;FrmXmlDom&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)&lt;br /&gt;
      Me.ClientSize = New System.Drawing.Size(360, 341)&lt;br /&gt;
      Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtConsole, Me.treXml, Me.cmdReset, Me.cmdPrint, Me.cmdBuild})&lt;br /&gt;
      Me.Name = &amp;quot;FrmXmlDom&amp;quot;&lt;br /&gt;
      Me.Text = &amp;quot;Xml Dom&amp;quot;&lt;br /&gt;
      Me.ResumeLayout(False)&lt;br /&gt;
   End Sub&lt;br /&gt;
#End Region&lt;br /&gt;
   &amp;quot; event handler for cmdBuild click event&lt;br /&gt;
   Private Sub cmdBuild_Click(ByVal sender As System.Object, _&lt;br /&gt;
      ByVal e As System.EventArgs) Handles cmdBuild.Click&lt;br /&gt;
      &amp;quot; determine if copy has been built already&lt;br /&gt;
      If Not copy Is Nothing Then&lt;br /&gt;
         Return &amp;quot; document already exists&lt;br /&gt;
      End If&lt;br /&gt;
      &amp;quot; instantiate XmlDocument and TreeNode&lt;br /&gt;
      copy = New XmlDocument()&lt;br /&gt;
      tree = New TreeNode()&lt;br /&gt;
      &amp;quot; add root node name to TreeNode and add&lt;br /&gt;
      &amp;quot; TreeNode to TreeView control&lt;br /&gt;
      tree.Text = source.Name &amp;quot; assigns #root&lt;br /&gt;
      treXml.Nodes.Add(tree)&lt;br /&gt;
      &amp;quot; build node and tree hierarchy&lt;br /&gt;
      BuildTree(source, copy, tree)&lt;br /&gt;
   End Sub &amp;quot; cmdBuild_Click&lt;br /&gt;
   &amp;quot; event handler for cmdPrint click event&lt;br /&gt;
   Private Sub cmdPrint_Click(ByVal sender As System.Object, _&lt;br /&gt;
      ByVal e As System.EventArgs) Handles cmdPrint.Click&lt;br /&gt;
      &amp;quot; exit if copy does not reference an XmlDocument&lt;br /&gt;
      If copy Is Nothing Then&lt;br /&gt;
         Return&lt;br /&gt;
      End If&lt;br /&gt;
      &amp;quot; create temporary XML file&lt;br /&gt;
      Dim file As TempFileCollection = New TempFileCollection()&lt;br /&gt;
      &amp;quot; create file that is deleted at program termination&lt;br /&gt;
      file.AddExtension(&amp;quot;xml&amp;quot;, False)&lt;br /&gt;
      Dim filename As String() = New String(0) {}&lt;br /&gt;
      file.CopyTo(filename, 0)&lt;br /&gt;
      &amp;quot; write XML data to disk&lt;br /&gt;
      Dim writer As XmlTextWriter = _&lt;br /&gt;
        New XmlTextWriter(filename(0), _&lt;br /&gt;
        System.Text.Encoding.UTF8)&lt;br /&gt;
      copy.WriteTo(writer)&lt;br /&gt;
      writer.Close()&lt;br /&gt;
      &amp;quot; parse and load temporary XML document&lt;br /&gt;
      Dim reader As XmlTextReader = _&lt;br /&gt;
         New XmlTextReader(filename(0))&lt;br /&gt;
      &amp;quot; read, format and display data&lt;br /&gt;
      While reader.Read&lt;br /&gt;
         If reader.NodeType = XmlNodeType.EndElement Then&lt;br /&gt;
            txtConsole.Text &amp;amp;= &amp;quot;/&amp;quot;&lt;br /&gt;
         End If&lt;br /&gt;
         If reader.Name &amp;lt;&amp;gt; String.Empty Then&lt;br /&gt;
            txtConsole.Text &amp;amp;= reader.Name &amp;amp; vbCrLf&lt;br /&gt;
         End If&lt;br /&gt;
         If reader.Value &amp;lt;&amp;gt; String.Empty Then&lt;br /&gt;
            txtConsole.Text &amp;amp;= vbTab &amp;amp; reader.Value &amp;amp; vbCrLf&lt;br /&gt;
         End If&lt;br /&gt;
      End While&lt;br /&gt;
      reader.Close()&lt;br /&gt;
   End Sub &amp;quot; cmdPrint_Click&lt;br /&gt;
   &amp;quot; handle cmdReset click event&lt;br /&gt;
   Private Sub cmdReset_Click(ByVal sender As System.Object, _&lt;br /&gt;
      ByVal e As System.EventArgs) Handles cmdReset.Click&lt;br /&gt;
      &amp;quot; remove TreeView nodes&lt;br /&gt;
      If Not tree Is Nothing Then&lt;br /&gt;
         treXml.Nodes.Remove(tree)&lt;br /&gt;
      End If&lt;br /&gt;
      treXml.Refresh() &amp;quot; force TreeView update&lt;br /&gt;
      &amp;quot; delete XmlDocument and tree&lt;br /&gt;
      copy = Nothing&lt;br /&gt;
      tree = Nothing&lt;br /&gt;
      txtConsole.Clear() &amp;quot; clear text box&lt;br /&gt;
   End Sub &amp;quot; cmdReset_Click&lt;br /&gt;
   &amp;quot; construct DOM tree&lt;br /&gt;
   Private Sub BuildTree(ByVal xmlSourceNode As XmlNode, _&lt;br /&gt;
      ByVal documentValue As XmlNode, _&lt;br /&gt;
      ByVal treeNode As TreeNode)&lt;br /&gt;
      &amp;quot; create XmlNodeReader to access XML document&lt;br /&gt;
      Dim nodeReader As XmlNodeReader = _&lt;br /&gt;
         New XmlNodeReader(xmlSourceNode)&lt;br /&gt;
      &amp;quot; represents current node in DOM tree&lt;br /&gt;
      Dim currentNode As XmlNode = Nothing&lt;br /&gt;
      &amp;quot; treeNode to add to existing tree&lt;br /&gt;
      Dim newNode As TreeNode = New TreeNode()&lt;br /&gt;
      &amp;quot; references modified node type for CreateNode&lt;br /&gt;
      Dim modifiedNodeType As XmlNodeType&lt;br /&gt;
      While nodeReader.Read&lt;br /&gt;
         &amp;quot; get current node type&lt;br /&gt;
         modifiedNodeType = nodeReader.NodeType&lt;br /&gt;
         &amp;quot; check for EndElement, store as Element&lt;br /&gt;
         If modifiedNodeType = XmlNodeType.EndElement Then&lt;br /&gt;
            modifiedNodeType = XmlNodeType.Element&lt;br /&gt;
         End If&lt;br /&gt;
         &amp;quot; create node copy&lt;br /&gt;
         currentNode = copy.CreateNode(modifiedNodeType, _&lt;br /&gt;
            nodeReader.Name, nodeReader.NamespaceURI)&lt;br /&gt;
         &amp;quot; build tree based on node type&lt;br /&gt;
         Select Case nodeReader.NodeType&lt;br /&gt;
            &amp;quot; if Text node, add its value to tree&lt;br /&gt;
         Case XmlNodeType.Text&lt;br /&gt;
               newNode.Text = nodeReader.Value&lt;br /&gt;
               treeNode.Nodes.Add(newNode)&lt;br /&gt;
               &amp;quot; append Text node value to currentNode data&lt;br /&gt;
               CType(currentNode, XmlText).AppendData _&lt;br /&gt;
                  (nodeReader.Value)&lt;br /&gt;
               documentValue.AppendChild(currentNode)&lt;br /&gt;
               &amp;quot; if EndElement, move up tree&lt;br /&gt;
            Case XmlNodeType.EndElement&lt;br /&gt;
               documentValue = documentValue.ParentNode&lt;br /&gt;
               treeNode = treeNode.Parent&lt;br /&gt;
               &amp;quot; if new element, add name and traverse tree&lt;br /&gt;
            Case XmlNodeType.Element&lt;br /&gt;
               &amp;quot; determine if element contains content&lt;br /&gt;
               If Not nodeReader.IsEmptyElement Then&lt;br /&gt;
                  &amp;quot; assign node text, add newNode as child&lt;br /&gt;
                  newNode.Text = nodeReader.Name&lt;br /&gt;
                  treeNode.Nodes.Add(newNode)&lt;br /&gt;
                  &amp;quot; set treeNode to last child&lt;br /&gt;
                  treeNode = newNode&lt;br /&gt;
                  documentValue.AppendChild(currentNode)&lt;br /&gt;
                  documentValue = documentValue.LastChild&lt;br /&gt;
               Else &amp;quot; do not traverse empty elements&lt;br /&gt;
                  &amp;quot; assign NodeType string to newNode&lt;br /&gt;
                  newNode.Text = nodeReader.NodeType.ToString&lt;br /&gt;
                  treeNode.Nodes.Add(newNode)&lt;br /&gt;
                  documentValue.AppendChild(currentNode)&lt;br /&gt;
               End If&lt;br /&gt;
            Case Else &amp;quot; all other types, display node type&lt;br /&gt;
               newNode.Text = nodeReader.NodeType.ToString&lt;br /&gt;
               treeNode.Nodes.Add(newNode)&lt;br /&gt;
               documentValue.AppendChild(currentNode)&lt;br /&gt;
         End Select&lt;br /&gt;
         newNode = New TreeNode()&lt;br /&gt;
      End While&lt;br /&gt;
      &amp;quot; update TreeView control&lt;br /&gt;
      treXml.ExpandAll()&lt;br /&gt;
      treXml.Refresh()&lt;br /&gt;
   End Sub &amp;quot; BuildTree&lt;br /&gt;
End Class &amp;quot; FrmXmlDom&lt;br /&gt;
&amp;quot; *************************************************************&lt;br /&gt;
&amp;quot; * (C) Copyright 2002 by Deitel &amp;amp; Associates, Inc.           *&lt;br /&gt;
&amp;quot; *     and Prentice Hall.                                    *&lt;br /&gt;
&amp;quot; * All Rights Reserved.                                      *&lt;br /&gt;
&amp;quot; *                                                           *&lt;br /&gt;
&amp;quot; * DISCLAIMER: The authors and publisher of this book have   *&lt;br /&gt;
&amp;quot; * used their best efforts in preparing the book. These      *&lt;br /&gt;
&amp;quot; * efforts include the development, research, and testing of *&lt;br /&gt;
&amp;quot; * the theories and programs to determine their              *&lt;br /&gt;
&amp;quot; * effectiveness. The authors and publisher make no warranty *&lt;br /&gt;
&amp;quot; * of any kind, expressed or implied, with regard to these   *&lt;br /&gt;
&amp;quot; * programs or to the documentation contained in these books.*&lt;br /&gt;
&amp;quot; * The authors and publisher shall not be liable in any event*&lt;br /&gt;
&amp;quot; * for incidental or consequential damages in connection     *&lt;br /&gt;
&amp;quot; * with, or arising out of, the furnishing, performance, or  *&lt;br /&gt;
&amp;quot; * use of these programs.                                    *&lt;br /&gt;
&amp;quot; *************************************************************&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==XML path navigator==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&amp;quot;Visual Basic.NET How to Program, Second Edition&lt;br /&gt;
&amp;quot;by Harvey M. Deitel (Author), Paul J. Deitel (Author), Tem R. Nieto (Author)&lt;br /&gt;
&amp;quot; Publisher: Prentice Hall; 2 edition (December 11, 2001)&lt;br /&gt;
&amp;quot; Language: English&lt;br /&gt;
&amp;quot; ISBN-10: 0130293636&lt;br /&gt;
&amp;quot; ISBN-13: 978-0130293633&lt;br /&gt;
&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
Imports System.Xml.XPath &lt;br /&gt;
public class FrmPathNavigatorDemo&lt;br /&gt;
   public Shared Sub Main&lt;br /&gt;
        Application.Run(New FrmPathNavigator)&lt;br /&gt;
   End Sub&lt;br /&gt;
End class&lt;br /&gt;
Public Class FrmPathNavigator&lt;br /&gt;
   Inherits Form&lt;br /&gt;
   &amp;quot; GroupBox contains Controls for locating XML file&lt;br /&gt;
   Friend WithEvents locateGroupBox As GroupBox&lt;br /&gt;
   Friend WithEvents cmdSelect As Button&lt;br /&gt;
   Friend WithEvents cboSelect As ComboBox&lt;br /&gt;
   Friend WithEvents txtSelect As TextBox&lt;br /&gt;
   &amp;quot; GroupBox contains Controls for navigating DOM tree&lt;br /&gt;
   Friend WithEvents navigateGroupBox As GroupBox&lt;br /&gt;
   Friend WithEvents cmdNext As Button&lt;br /&gt;
   Friend WithEvents cmdPrevious As Button&lt;br /&gt;
   Friend WithEvents cmdParent As Button&lt;br /&gt;
   Friend WithEvents cmdFirstChild As Button&lt;br /&gt;
   &amp;quot; TreeView displays DOM-tree results&lt;br /&gt;
   Friend WithEvents trePath As TreeView&lt;br /&gt;
   &amp;quot; navigator to traverse document&lt;br /&gt;
   Private xPath As XPathNavigator&lt;br /&gt;
   &amp;quot; references document for use by XPathNavigator&lt;br /&gt;
   Private document As XPathDocument&lt;br /&gt;
   &amp;quot; references TreeNode list used by TreeView control&lt;br /&gt;
   Private tree As TreeNode&lt;br /&gt;
   Public Sub New()&lt;br /&gt;
      MyBase.New()&lt;br /&gt;
      &amp;quot; This call is required by the Windows Form Designer.&lt;br /&gt;
      InitializeComponent()&lt;br /&gt;
      &amp;quot; Add any initialization after the &lt;br /&gt;
      &amp;quot; InitializeComponent() call&lt;br /&gt;
      &amp;quot; load in XML document&lt;br /&gt;
      document = New XPathDocument(&amp;quot;YourFile.xml&amp;quot;)&lt;br /&gt;
      &amp;quot; create nagivator&lt;br /&gt;
      xPath = document.CreateNavigator&lt;br /&gt;
      &amp;quot; create root node for TreeNodes&lt;br /&gt;
      tree = New TreeNode()&lt;br /&gt;
      tree.Text = xPath.NodeType.ToString &amp;quot; #root&lt;br /&gt;
      trePath.Nodes.Add(tree)             &amp;quot; add tree&lt;br /&gt;
      &amp;quot; update TreeView control&lt;br /&gt;
      trePath.ExpandAll()&lt;br /&gt;
      trePath.Refresh()&lt;br /&gt;
      trePath.SelectedNode = tree         &amp;quot; highlight root&lt;br /&gt;
   End Sub &amp;quot; New&lt;br /&gt;
#Region &amp;quot; Windows Form Designer generated code &amp;quot;&lt;br /&gt;
   &amp;quot;Form overrides dispose to clean up the component list.&lt;br /&gt;
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)&lt;br /&gt;
      If disposing Then&lt;br /&gt;
         If Not (components Is Nothing) Then&lt;br /&gt;
            components.Dispose()&lt;br /&gt;
         End If&lt;br /&gt;
      End If&lt;br /&gt;
      MyBase.Dispose(disposing)&lt;br /&gt;
   End Sub&lt;br /&gt;
   &amp;quot;Required by the Windows Form Designer&lt;br /&gt;
   Private components As System.ruponentModel.Container&lt;br /&gt;
   &amp;quot;NOTE: The following procedure is required by the Windows Form Designer&lt;br /&gt;
   &amp;quot;It can be modified using the Windows Form Designer.  &lt;br /&gt;
   &amp;quot;Do not modify it using the code editor.&lt;br /&gt;
   &amp;lt;System.Diagnostics.DebuggerStepThrough()&amp;gt; Private Sub InitializeComponent()&lt;br /&gt;
      Me.cboSelect = New System.Windows.Forms.ruboBox()&lt;br /&gt;
      Me.trePath = New System.Windows.Forms.TreeView()&lt;br /&gt;
      Me.navigateGroupBox = New System.Windows.Forms.GroupBox()&lt;br /&gt;
      Me.cmdFirstChild = New System.Windows.Forms.Button()&lt;br /&gt;
      Me.cmdParent = New System.Windows.Forms.Button()&lt;br /&gt;
      Me.cmdNext = New System.Windows.Forms.Button()&lt;br /&gt;
      Me.cmdPrevious = New System.Windows.Forms.Button()&lt;br /&gt;
      Me.txtSelect = New System.Windows.Forms.TextBox()&lt;br /&gt;
      Me.locateGroupBox = New System.Windows.Forms.GroupBox()&lt;br /&gt;
      Me.cmdSelect = New System.Windows.Forms.Button()&lt;br /&gt;
      Me.navigateGroupBox.SuspendLayout()&lt;br /&gt;
      Me.locateGroupBox.SuspendLayout()&lt;br /&gt;
      Me.SuspendLayout()&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;cboSelect&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.cboSelect.DropDownWidth = 121&lt;br /&gt;
      Me.cboSelect.Items.AddRange(New Object() {&amp;quot;/sports&amp;quot;, &amp;quot;/sports/game/name&amp;quot;, &amp;quot;/sports/game/paragraph&amp;quot;, &amp;quot;/sports/game [name=&amp;quot;Cricket&amp;quot;]&amp;quot;})&lt;br /&gt;
      Me.cboSelect.Location = New System.Drawing.Point(104, 32)&lt;br /&gt;
      Me.cboSelect.Name = &amp;quot;cboSelect&amp;quot;&lt;br /&gt;
      Me.cboSelect.Size = New System.Drawing.Size(224, 24)&lt;br /&gt;
      Me.cboSelect.TabIndex = 1&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;trePath&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.trePath.FullRowSelect = True&lt;br /&gt;
      Me.trePath.HideSelection = False&lt;br /&gt;
      Me.trePath.ImageIndex = -1&lt;br /&gt;
      Me.trePath.Location = New System.Drawing.Point(8, 272)&lt;br /&gt;
      Me.trePath.Name = &amp;quot;trePath&amp;quot;&lt;br /&gt;
      Me.trePath.SelectedImageIndex = -1&lt;br /&gt;
      Me.trePath.Size = New System.Drawing.Size(336, 136)&lt;br /&gt;
      Me.trePath.TabIndex = 2&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;navigateGroupBox&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.navigateGroupBox.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdFirstChild, Me.cmdParent, Me.cmdNext, Me.cmdPrevious})&lt;br /&gt;
      Me.navigateGroupBox.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))&lt;br /&gt;
      Me.navigateGroupBox.Location = New System.Drawing.Point(84, 144)&lt;br /&gt;
      Me.navigateGroupBox.Name = &amp;quot;navigateGroupBox&amp;quot;&lt;br /&gt;
      Me.navigateGroupBox.Size = New System.Drawing.Size(184, 120)&lt;br /&gt;
      Me.navigateGroupBox.TabIndex = 1&lt;br /&gt;
      Me.navigateGroupBox.TabStop = False&lt;br /&gt;
      Me.navigateGroupBox.Text = &amp;quot;Navigation Controls&amp;quot;&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;cmdFirstChild&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.cmdFirstChild.Location = New System.Drawing.Point(104, 56)&lt;br /&gt;
      Me.cmdFirstChild.Name = &amp;quot;cmdFirstChild&amp;quot;&lt;br /&gt;
      Me.cmdFirstChild.TabIndex = 5&lt;br /&gt;
      Me.cmdFirstChild.Text = &amp;quot;First Child&amp;quot;&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;cmdParent&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.cmdParent.Location = New System.Drawing.Point(8, 56)&lt;br /&gt;
      Me.cmdParent.Name = &amp;quot;cmdParent&amp;quot;&lt;br /&gt;
      Me.cmdParent.TabIndex = 4&lt;br /&gt;
      Me.cmdParent.Text = &amp;quot;Parent&amp;quot;&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;cmdNext&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.cmdNext.Location = New System.Drawing.Point(56, 88)&lt;br /&gt;
      Me.cmdNext.Name = &amp;quot;cmdNext&amp;quot;&lt;br /&gt;
      Me.cmdNext.TabIndex = 3&lt;br /&gt;
      Me.cmdNext.Text = &amp;quot;Next&amp;quot;&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;cmdPrevious&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.cmdPrevious.Location = New System.Drawing.Point(56, 24)&lt;br /&gt;
      Me.cmdPrevious.Name = &amp;quot;cmdPrevious&amp;quot;&lt;br /&gt;
      Me.cmdPrevious.TabIndex = 2&lt;br /&gt;
      Me.cmdPrevious.Text = &amp;quot;Previous&amp;quot;&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;txtSelect&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.txtSelect.BackColor = System.Drawing.SystemColors.Info&lt;br /&gt;
      Me.txtSelect.Location = New System.Drawing.Point(8, 64)&lt;br /&gt;
      Me.txtSelect.Multiline = True&lt;br /&gt;
      Me.txtSelect.Name = &amp;quot;txtSelect&amp;quot;&lt;br /&gt;
      Me.txtSelect.ReadOnly = True&lt;br /&gt;
      Me.txtSelect.Size = New System.Drawing.Size(320, 56)&lt;br /&gt;
      Me.txtSelect.TabIndex = 2&lt;br /&gt;
      Me.txtSelect.Text = &amp;quot;&amp;quot;&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;locateGroupBox&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.locateGroupBox.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtSelect, Me.cmdSelect, Me.cboSelect})&lt;br /&gt;
      Me.locateGroupBox.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))&lt;br /&gt;
      Me.locateGroupBox.Location = New System.Drawing.Point(8, 8)&lt;br /&gt;
      Me.locateGroupBox.Name = &amp;quot;locateGroupBox&amp;quot;&lt;br /&gt;
      Me.locateGroupBox.Size = New System.Drawing.Size(336, 128)&lt;br /&gt;
      Me.locateGroupBox.TabIndex = 0&lt;br /&gt;
      Me.locateGroupBox.TabStop = False&lt;br /&gt;
      Me.locateGroupBox.Text = &amp;quot;Locate Element&amp;quot;&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;cmdSelect&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.cmdSelect.Location = New System.Drawing.Point(8, 32)&lt;br /&gt;
      Me.cmdSelect.Name = &amp;quot;cmdSelect&amp;quot;&lt;br /&gt;
      Me.cmdSelect.TabIndex = 1&lt;br /&gt;
      Me.cmdSelect.Text = &amp;quot;Select&amp;quot;&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      &amp;quot;FrmPathNavigator&lt;br /&gt;
      &amp;quot;&lt;br /&gt;
      Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)&lt;br /&gt;
      Me.ClientSize = New System.Drawing.Size(352, 413)&lt;br /&gt;
      Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.trePath, Me.navigateGroupBox, Me.locateGroupBox})&lt;br /&gt;
      Me.Name = &amp;quot;FrmPathNavigator&amp;quot;&lt;br /&gt;
      Me.Text = &amp;quot;Path Navigator&amp;quot;&lt;br /&gt;
      Me.navigateGroupBox.ResumeLayout(False)&lt;br /&gt;
      Me.locateGroupBox.ResumeLayout(False)&lt;br /&gt;
      Me.ResumeLayout(False)&lt;br /&gt;
   End Sub&lt;br /&gt;
#End Region&lt;br /&gt;
   &amp;quot; traverse to first child&lt;br /&gt;
   Private Sub cmdFirstChild_Click( _&lt;br /&gt;
      ByVal sender As System.Object, _&lt;br /&gt;
      ByVal e As System.EventArgs) Handles cmdFirstChild.Click&lt;br /&gt;
      Dim newTreeNode As TreeNode&lt;br /&gt;
      If xPath.MoveToFirstChild Then&lt;br /&gt;
         newTreeNode = New TreeNode() &amp;quot; create new node&lt;br /&gt;
         DetermineType(newTreeNode, xPath)&lt;br /&gt;
         tree.Nodes.Add(newTreeNode)&lt;br /&gt;
         tree = newTreeNode &amp;quot; assign tree newTreeNode&lt;br /&gt;
         trePath.ExpandAll()&lt;br /&gt;
         trePath.Refresh()&lt;br /&gt;
         trePath.SelectedNode = tree&lt;br /&gt;
      Else &lt;br /&gt;
         Console.WriteLine(&amp;quot;Current Node has no children.&amp;quot;)&lt;br /&gt;
      End If&lt;br /&gt;
   End Sub &amp;quot; cmdFirstChild_Click&lt;br /&gt;
   Private Sub cmdParent_Click(ByVal sender As System.Object, _&lt;br /&gt;
      ByVal e As System.EventArgs) Handles cmdParent.Click&lt;br /&gt;
      If xPath.MoveToParent Then&lt;br /&gt;
         tree = tree.Parent&lt;br /&gt;
         Dim count As Integer = tree.GetNodeCount(False)&lt;br /&gt;
         Dim i As Integer&lt;br /&gt;
         For i = 0 To count - 1&lt;br /&gt;
            tree.Nodes.Remove(tree.FirstNode)&lt;br /&gt;
         Next&lt;br /&gt;
         trePath.ExpandAll()&lt;br /&gt;
         trePath.Refresh()&lt;br /&gt;
         trePath.SelectedNode = tree&lt;br /&gt;
      Else &lt;br /&gt;
         Console.WriteLine(&amp;quot;Current node has no parent.&amp;quot;, &amp;quot;&amp;quot;, _&lt;br /&gt;
            MessageBoxButtons.OK, MessageBoxIcon.Information)&lt;br /&gt;
      End If&lt;br /&gt;
   End Sub &amp;quot; cmdParent_Click&lt;br /&gt;
   Private Sub cmdNext_Click(ByVal sender As System.Object, _&lt;br /&gt;
      ByVal e As System.EventArgs) Handles cmdNext.Click&lt;br /&gt;
      Dim newTreeNode As TreeNode = Nothing&lt;br /&gt;
      Dim newNode As TreeNode = Nothing&lt;br /&gt;
      If xPath.MoveToNext Then&lt;br /&gt;
         newTreeNode = tree.Parent &amp;quot; get parent node&lt;br /&gt;
         newNode = New TreeNode() &amp;quot; create new node&lt;br /&gt;
         DetermineType(newNode, xPath)&lt;br /&gt;
         newTreeNode.Nodes.Add(newNode)&lt;br /&gt;
         tree = newNode&lt;br /&gt;
         trePath.ExpandAll()&lt;br /&gt;
         trePath.Refresh()&lt;br /&gt;
         trePath.SelectedNode = tree&lt;br /&gt;
      Else &lt;br /&gt;
         Console.WriteLine(&amp;quot;Current node is last sibling.&amp;quot;, &amp;quot;&amp;quot;, _&lt;br /&gt;
            MessageBoxButtons.OK, MessageBoxIcon.Information)&lt;br /&gt;
      End If&lt;br /&gt;
   End Sub &lt;br /&gt;
   Private Sub cmdPrevious_Click( _&lt;br /&gt;
      ByVal sender As System.Object, _&lt;br /&gt;
      ByVal e As System.EventArgs) Handles cmdPrevious.Click&lt;br /&gt;
      Dim parentTreeNode As TreeNode = Nothing&lt;br /&gt;
      If xPath.MoveToPrevious Then&lt;br /&gt;
         parentTreeNode = tree.Parent &amp;quot; get parent node&lt;br /&gt;
         &amp;quot; delete current node&lt;br /&gt;
         parentTreeNode.Nodes.Remove(tree)&lt;br /&gt;
         &amp;quot; move to previous node&lt;br /&gt;
         tree = parentTreeNode.LastNode&lt;br /&gt;
         &amp;quot; update TreeView control&lt;br /&gt;
         trePath.ExpandAll()&lt;br /&gt;
         trePath.Refresh()&lt;br /&gt;
         trePath.SelectedNode = tree&lt;br /&gt;
      Else &amp;quot; if current node has no previous siblings&lt;br /&gt;
         MessageBox.Show(&amp;quot;Current node is first sibling.&amp;quot;, &amp;quot;&amp;quot;, _&lt;br /&gt;
            MessageBoxButtons.OK, MessageBoxIcon.Information)&lt;br /&gt;
      End If&lt;br /&gt;
   End Sub &amp;quot; cmdPrevious_Click&lt;br /&gt;
   &amp;quot; process cmdSelect_Click event&lt;br /&gt;
   Private Sub cmdSelect_Click(ByVal sender As System.Object, _&lt;br /&gt;
      ByVal e As System.EventArgs) Handles cmdSelect.Click&lt;br /&gt;
      Dim iterator As XPathNodeIterator &amp;quot; enables node iteration&lt;br /&gt;
      &amp;quot; get specified node from ComboBox&lt;br /&gt;
      Try&lt;br /&gt;
         iterator = xPath.Select(cboSelect.Text)&lt;br /&gt;
         DisplayIterator(iterator) &amp;quot; print selection&lt;br /&gt;
         &amp;quot; catch invalid expressions&lt;br /&gt;
      Catch argumentException As System.ArgumentException&lt;br /&gt;
         MessageBox.Show(argumentException.Message, &amp;quot;Error&amp;quot;, _&lt;br /&gt;
            MessageBoxButtons.OK, MessageBoxIcon.Error)&lt;br /&gt;
      End Try&lt;br /&gt;
   End Sub &amp;quot; cmdSelect_Click&lt;br /&gt;
   &amp;quot; print values for XPathNodeIterator&lt;br /&gt;
   Private Sub DisplayIterator( _&lt;br /&gt;
      ByVal iterator As XPathNodeIterator)&lt;br /&gt;
      txtSelect.Clear()&lt;br /&gt;
      &amp;quot; prints selected node&amp;quot;s values&lt;br /&gt;
      While iterator.MoveNext&lt;br /&gt;
         txtSelect.Text &amp;amp;= iterator.Current.Value.Trim &amp;amp; vbCrLf&lt;br /&gt;
      End While&lt;br /&gt;
   End Sub &amp;quot; DisplayIterator&lt;br /&gt;
   &amp;quot; determine if TreeNode should display current node&lt;br /&gt;
   &amp;quot; name or value&lt;br /&gt;
   Private Sub DetermineType(ByVal node As TreeNode, _&lt;br /&gt;
      ByVal xPath As XPathNavigator)&lt;br /&gt;
      &amp;quot; determine NodeType&lt;br /&gt;
      Select Case xPath.NodeType&lt;br /&gt;
         Case XPathNodeType.Element &amp;quot; if Element, get its name&lt;br /&gt;
            &amp;quot; get current node name, and remove whitespaces&lt;br /&gt;
            node.Text = xPath.Name.Trim&lt;br /&gt;
         Case Else  &amp;quot; obtain node values&lt;br /&gt;
            &amp;quot; get current node value and remove whitespaces&lt;br /&gt;
            node.Text = xPath.Value.Trim&lt;br /&gt;
      End Select&lt;br /&gt;
   End Sub&lt;br /&gt;
End Class&lt;br /&gt;
&lt;br /&gt;
&amp;quot; *************************************************************&lt;br /&gt;
&amp;quot; * (C) Copyright 2002 by Deitel &amp;amp; Associates, Inc.           *&lt;br /&gt;
&amp;quot; *     and Prentice Hall.                                    *&lt;br /&gt;
&amp;quot; * All Rights Reserved.                                      *&lt;br /&gt;
&amp;quot; *                                                           *&lt;br /&gt;
&amp;quot; * DISCLAIMER: The authors and publisher of this book have   *&lt;br /&gt;
&amp;quot; * used their best efforts in preparing the book. These      *&lt;br /&gt;
&amp;quot; * efforts include the development, research, and testing of *&lt;br /&gt;
&amp;quot; * the theories and programs to determine their              *&lt;br /&gt;
&amp;quot; * effectiveness. The authors and publisher make no warranty *&lt;br /&gt;
&amp;quot; * of any kind, expressed or implied, with regard to these   *&lt;br /&gt;
&amp;quot; * programs or to the documentation contained in these books.*&lt;br /&gt;
&amp;quot; * The authors and publisher shall not be liable in any event*&lt;br /&gt;
&amp;quot; * for incidental or consequential damages in connection     *&lt;br /&gt;
&amp;quot; * with, or arising out of, the furnishing, performance, or  *&lt;br /&gt;
&amp;quot; * use of these programs.                                    *&lt;br /&gt;
&amp;quot; *************************************************************&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>