XmlLinkedNode.PreviousSibling Property

 

Gets the node immediately preceding this node.

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)

public override XmlNode PreviousSibling { get; }

Property Value

Type: System.Xml.XmlNode

The preceding XmlNode or null if one does not exist.

The following example displays the last two books.

using System;
using System.Xml;

public class Sample {

  public static void Main() {

      XmlDocument doc = new XmlDocument();
      doc.Load("books.xml");

      XmlNode lastNode = doc.DocumentElement.LastChild;
      Console.WriteLine("Last book...");
      Console.WriteLine(lastNode.OuterXml);

      XmlNode prevNode = lastNode.PreviousSibling;
      Console.WriteLine("\r\nPrevious book...");
      Console.WriteLine(prevNode.OuterXml);  
  }
}

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top
Show: