XNode.NodesBeforeSelf returns a collection of the sibling nodes before this node : XML Node « XML « VB.Net





XNode.NodesBeforeSelf returns a collection of the sibling nodes before this node

 
Imports System
Imports System.Xml
Imports System.Xml.Schema
Imports System.Linq
Imports System.Collections
Imports System.Collections.Generic
Class MainClass

    Shared Sub Main()
        Dim xmlTree As XElement = New XElement("Root", _
            New XText("Text content."), _
            New XElement("Child1", "child1 content"), _
            New XElement("Child2", "child2 content"), _
            New XText("More text content."), _
            New XElement("child3", "child3 content") _
        )

        Dim child As XElement = xmlTree.Element("Child2")
        Dim nodes As IEnumerable(Of XNode) = _
            From node In child.NodesBeforeSelf() _
            Select node
        For Each node As XNode In nodes
            Dim s As String = ""
            If node.NodeType = XmlNodeType.Text Then
                s = DirectCast(node, XText).Value
            End If
            Console.WriteLine("Node type: {0}  {1}", node.NodeType, s)
        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.Loop through the xml nodes
30.XNode.AddAfterSelf adds the specified content immediately after this node.
31.XNode.AddAfterSelf (Object[]) adds the specified content immediately after this node.
32.XNode.AddBeforeSelf (Object) adds the specified content immediately before this node.
33.XNode.AddBeforeSelf (Object[]) adds the specified content immediately before this node.
34.XNode.Ancestors returns a collection of the ancestor elements of this node.
35.XNode.Ancestors (XName) returns a filtered collection of the ancestor elements of this node
36.XNode.ElementsAfterSelf returns a collection of the sibling elements after this node, in document order.
37.XNode.ElementsAfterSelf (XName) returns a filtered collection of the sibling elements after this node
38.XNode.ElementsBeforeSelf returns a collection of the sibling elements before this node
39.XNode.ElementsBeforeSelf returns a filtered collection of the sibling elements before this node
40.XNode.IsAfter determines if the current node appears after a specified node
41.XNode.IsBefore determines if the current node appears before a specified node
42.XNode.NextNode Property gets the next sibling node of this node.
43.XNode.NodesAfterSelf returns a collection of the sibling nodes after 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.