XmlLinkedNode.PreviousSibling Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the node immediately preceding this node.
public:
virtual property System::Xml::XmlNode ^ PreviousSibling { System::Xml::XmlNode ^ get(); };
public override System.Xml.XmlNode PreviousSibling { get; }
public override System.Xml.XmlNode? PreviousSibling { get; }
member this.PreviousSibling : System.Xml.XmlNode
Public Overrides ReadOnly Property PreviousSibling As XmlNode
Property Value
The preceding XmlNode or null
if one does not exist.
Examples
The following example displays the last two books.
#using <System.Xml.dll>
using namespace System;
using namespace System::Xml;
int main()
{
XmlDocument^ doc = gcnew 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 );
}
using System;
using System.Xml;
public class Sample5
{
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);
}
}
Imports System.Xml
public class Sample
public shared sub Main()
Dim doc as XmlDocument = new XmlDocument()
doc.Load("books.xml")
Dim lastNode as XmlNode = doc.DocumentElement.LastChild
Console.WriteLine("Last book...")
Console.WriteLine(lastNode.OuterXml)
Dim prevNode as XmlNode = lastNode.PreviousSibling
Console.WriteLine(ControlChars.LF + "Previous book...")
Console.WriteLine(prevNode.OuterXml)
end sub
end class
Applies to
See also
GitHub पर हमारे साथ सहयोग करें
इस सामग्री का स्रोत GitHub पर पाया जा सकता है, जहाँ आप समस्याएँ बना और समीक्षा भी कर सकते हैं और अनुरोध खींच सकते हैं. अधिक जानकारी के लिए, हमारे योगदानकर्ता गाइड देखें.