Returns a collection of the sibling nodes after this node, in document order. : Nodes « XML LINQ « C# / C Sharp






Returns a collection of the sibling nodes after this node, in document order.

  

using System;
using System.Linq;
using System.IO;
using System.Xml;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;

public class MainClass
{
    public static void Main()
    {
        XElement xmlTree = new XElement("Root",
            new XText("Text content."),
            new XElement("A1", "A1 content"),
            new XElement("A2", "A2 content"),
            new XText("More text content."),
            new XElement("A3", "A3 content")
        );
        XElement child = xmlTree.Element("A2");
        IEnumerable<XNode> nodes =
            from node in child.NodesAfterSelf()
            select node;
        foreach (XNode node in nodes)
        {
            Console.WriteLine("Node type: {0}  {1}",
                node.NodeType,
                node.NodeType == XmlNodeType.Text ? (node as XText).Value : "");
        }
    }
}

   
    
  








Related examples in the same category

1.Calling the Only Nodes Prototype
2.Traversing Backward from an XElement Object via the PreviousNode Property
3.Adds the specified content immediately after this node.
4.Adds the specified content immediately before this node.
5.Returns a collection of the ancestor elements of this node.
6.Returns a filtered collection of the ancestor elements of this node.
7.Creates an XmlReader for this node.
8.Use hard coded xsl to convert xml document
9.Returns a collection of the sibling elements after this node, in document order.
10.Returns a filtered collection of the sibling elements after this node, in document order.
11.Returns a collection of the sibling elements before this node, in document order.
12.Returns a filtered collection of the sibling elements before this node, in document order.
13.Determines if the current node appears after a specified node in terms of document order.
14.Determines if the current node appears before a specified node in terms of document order.
15.Gets the next sibling node of this node.
16.Returns a collection of the sibling nodes before this node, in document order.
17.Gets the previous sibling node of this node.
18.Removes this node from its parent.
19.Replaces this node with the specified content.
20.Returns the XML for this node, optionally disabling formatting.
21.Returns the indented XML for this node.
22.Writes this node to an XmlWriter.