PreviousSibling Property

XmlNode.PreviousSibling Property


Gets the node immediately preceding this node.

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

public virtual XmlNode PreviousSibling { get; }

Property Value

Type: System.Xml.XmlNode

The preceding XmlNode. If there is no preceding node, null is returned.

The following example displays all the books in the XML document.

using System;
using System.Xml;

public class Sample {

  public static void Main() {

      XmlDocument doc = new XmlDocument();

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

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

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft