<?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%2FXML%2FXML_Tree</id>
		<title>VB.Net/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%2FXML%2FXML_Tree"/>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net/XML/XML_Tree&amp;action=history"/>
		<updated>2026-04-05T08:17:28Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net/XML/XML_Tree&amp;diff=300&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/XML/XML_Tree&amp;diff=300&amp;oldid=prev"/>
				<updated>2010-05-26T16:40:06Z</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/XML/XML_Tree&amp;diff=301&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net/XML/XML_Tree&amp;diff=301&amp;oldid=prev"/>
				<updated>2010-05-26T12:42:34Z</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;==Use Tree to Display XML document==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&lt;br /&gt;
       &lt;br /&gt;
&amp;quot; *************************************************************&lt;br /&gt;
&amp;quot; * (C) Copyright 2003 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; *************************************************************&lt;br /&gt;
       &lt;br /&gt;
Imports System.Xml&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
Imports System.CodeDom.rupiler&lt;br /&gt;
Public Class MainClass&lt;br /&gt;
   Shared Sub Main()&lt;br /&gt;
       Dim form1 As Form = New FrmXmlDom()&lt;br /&gt;
       Application.Run(form1)&lt;br /&gt;
   End Sub &amp;quot; Main&lt;br /&gt;
End Class&lt;br /&gt;
 &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;ExampleCode.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;
   Private Sub cmdBuild_Click(ByVal sender As System.Object, _&lt;br /&gt;
      ByVal e As System.EventArgs) Handles cmdBuild.Click&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;
      copy = New XmlDocument()&lt;br /&gt;
      tree = New TreeNode()&lt;br /&gt;
      tree.Text = source.Name &amp;quot; assigns #root&lt;br /&gt;
      treXml.Nodes.Add(tree)&lt;br /&gt;
      BuildTree(source, copy, tree)&lt;br /&gt;
   End Sub &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;
      If copy Is Nothing Then&lt;br /&gt;
         Return&lt;br /&gt;
      End If&lt;br /&gt;
      Dim file As TempFileCollection = New TempFileCollection()&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;
      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;
      Dim reader As XmlTextReader = _&lt;br /&gt;
         New XmlTextReader(filename(0))&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 &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;
      If Not tree Is Nothing Then&lt;br /&gt;
         treXml.Nodes.Remove(tree)&lt;br /&gt;
      End If&lt;br /&gt;
      treXml.Refresh() &lt;br /&gt;
      copy = Nothing&lt;br /&gt;
      tree = Nothing&lt;br /&gt;
      txtConsole.Clear() &lt;br /&gt;
   End Sub &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;
      Dim nodeReader As XmlNodeReader = _&lt;br /&gt;
         New XmlNodeReader(xmlSourceNode)&lt;br /&gt;
      Dim currentNode As XmlNode = Nothing&lt;br /&gt;
      Dim newNode As TreeNode = New TreeNode()&lt;br /&gt;
      Dim modifiedNodeType As XmlNodeType&lt;br /&gt;
      While nodeReader.Read&lt;br /&gt;
         modifiedNodeType = nodeReader.NodeType&lt;br /&gt;
         If modifiedNodeType = XmlNodeType.EndElement Then&lt;br /&gt;
            modifiedNodeType = XmlNodeType.Element&lt;br /&gt;
         End If&lt;br /&gt;
         currentNode = copy.CreateNode(modifiedNodeType, _&lt;br /&gt;
            nodeReader.Name, nodeReader.NamespaceURI)&lt;br /&gt;
         Select Case nodeReader.NodeType&lt;br /&gt;
         Case XmlNodeType.Text&lt;br /&gt;
               newNode.Text = nodeReader.Value&lt;br /&gt;
               treeNode.Nodes.Add(newNode)&lt;br /&gt;
               CType(currentNode, XmlText).AppendData _&lt;br /&gt;
                  (nodeReader.Value)&lt;br /&gt;
               documentValue.AppendChild(currentNode)&lt;br /&gt;
            Case XmlNodeType.EndElement&lt;br /&gt;
               documentValue = documentValue.ParentNode&lt;br /&gt;
               treeNode = treeNode.Parent&lt;br /&gt;
            Case XmlNodeType.Element&lt;br /&gt;
               If Not nodeReader.IsEmptyElement Then&lt;br /&gt;
                  newNode.Text = nodeReader.Name&lt;br /&gt;
                  treeNode.Nodes.Add(newNode)&lt;br /&gt;
                  treeNode = newNode&lt;br /&gt;
                  documentValue.AppendChild(currentNode)&lt;br /&gt;
                  documentValue = documentValue.LastChild&lt;br /&gt;
               Else &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 &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;
      treXml.ExpandAll()&lt;br /&gt;
      treXml.Refresh()&lt;br /&gt;
   End Sub&lt;br /&gt;
End Class &lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>