다음을 통해 공유


XmlLinkedNode.PreviousSibling 속성

정의

이 노드 바로 앞에 있는 노드를 가져옵니다.

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

속성 값

XmlNode

앞에 있는 XmlNode이거나, 노드가 없으면 null입니다.

예제

다음은 마지막 두 권의 책을 표시하는 예제입니다.

#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

적용 대상

추가 정보