Loop through the xml nodes : XML Node « XML « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Date Time
8.Development
9.Event
10.File Directory
11.Generics
12.GUI
13.Internationalization I18N
14.Language Basics
15.LINQ
16.Network Remote
17.Reflection
18.Security
19.Thread
20.Windows Presentation Foundation
21.Windows System
22.XML
23.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » XML » XML NodeScreenshots 
Loop through the xml nodes
 

Imports System
Imports System.Xml
Imports System.Xml.XPath

Public Class MainClass

    Public Shared Sub Main()
        Dim xmlTree As XDocument = _ 
            <?xml version="1.0" encoding="utf-8"?>
            <!--a comment-->
            <?xml-stylesheet type='text/xsl' href='hello.xsl'?>
            <Root Att="attContent">
                <Child1>content</Child1>
                <Child2>Text content</Child2>
            </Root>
        For Each node In xmlTree.Nodes
            Console.WriteLine(node.NodeType.ToString())
            If node.NodeType = XmlNodeType.Element Then
                For Each att In DirectCast(node, XElement).Attributes
                    Console.WriteLine(att.NodeType.ToString())
                Next
                For Each node2 In DirectCast (node, XElement).Nodes()
                    Console.WriteLine(node2.NodeType.ToString())
                    If node2.NodeType = XmlNodeType.Element Then
                        For Each node3 In DirectCast (node2, XElement).Nodes
                            Console.WriteLine(node3.NodeType.ToString())
                        Next
                    End If
                Next
            End If
        Next
    End Sub
End Class

   
  
Related examples in the same category
1.Creates an XmlSignificantWhitespace node.
2.Gets the node containing the DOCTYPE declaration.
3.Imports a node from another document to the current document.
4.Gets a value indicating whether the current node is read-only.
5.Creates a duplicate of this node.
6.Gets or sets the concatenated values of the node and all its children.
7.Gets the local name of the current node.
8.Gets the qualified name of the node.
9.Gets the node immediately following this node.
10.Gets the node immediately preceding this node.
11.Adds node to the end of the list of child nodes
12.Gets all the child nodes of the node.
13.Creates a duplicate of this node.
14.Gets the first child of the node.
15.Gets the markup representing this node and all its child nodes.
16.Adds node to the beginning of the list of child nodes for this node.
17.Removes specified child node.
18.Replaces the child node oldChild with newChild node.
19.Selects a list of nodes matching the XPath expression.
20.Handles NodeChanged, NodeChanging, NodeInserted, NodeInserting, NodeRemoved and NodeRemoving events.
21.Calls MoveToContent and tests if the current content node is a start tag or empty element tag
22.Select all the child nodes of the book node
23.Select all the ancestor nodes of the title node
24.Extensions.Ancestors(T) returns a collection of elements that contains the ancestors of every node
25.Extensions.DescendantNodes(T)
26.Extensions.InDocumentOrder(T) returns a collection of nodes that contains all nodes in the source collection
27.Extensions.Nodes(T) Method returns a collection of the child nodes of every document and element
28.Extensions.Remove(T) removes every node in the source collection from its parent node.
29.XNode.AddAfterSelf adds the specified content immediately after this node.
30.XNode.AddAfterSelf (Object[]) adds the specified content immediately after this node.
31.XNode.AddBeforeSelf (Object) adds the specified content immediately before this node.
32.XNode.AddBeforeSelf (Object[]) adds the specified content immediately before this node.
33.XNode.Ancestors returns a collection of the ancestor elements of this node.
34.XNode.Ancestors (XName) returns a filtered collection of the ancestor elements of this node
35.XNode.ElementsAfterSelf returns a collection of the sibling elements after this node, in document order.
36.XNode.ElementsAfterSelf (XName) returns a filtered collection of the sibling elements after this node
37.XNode.ElementsBeforeSelf returns a collection of the sibling elements before this node
38.XNode.ElementsBeforeSelf returns a filtered collection of the sibling elements before this node
39.XNode.IsAfter determines if the current node appears after a specified node
40.XNode.IsBefore determines if the current node appears before a specified node
41.XNode.NextNode Property gets the next sibling node of this node.
42.XNode.NodesAfterSelf returns a collection of the sibling nodes after this node
43.XNode.NodesBeforeSelf returns a collection of the sibling nodes before this node
44.XNode.PreviousNode Property gets the previous sibling node of this node.
45.XNode.Remove removes this node from its parent.
46.XNode.ReplaceWith replaces this node with the specified content.
47.XNode.ReplaceWith replaces this node with the specified content.
48.XNode.ToString returns the XML for this node, optionally disabling formatting.
49.XNode.ToString returns the indented XML for this node.
50.XObject.NodeType Property gets the node type for this XObject.
w_ww___.___j___a___v_a2__s._c___o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.