XmlNode.NextSibling 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 following this node.
public:
virtual property System::Xml::XmlNode ^ NextSibling { System::Xml::XmlNode ^ get(); };
public virtual System.Xml.XmlNode NextSibling { get; }
public virtual System.Xml.XmlNode? NextSibling { get; }
member this.NextSibling : System.Xml.XmlNode
Public Overridable ReadOnly Property NextSibling As XmlNode
Property Value
The next XmlNode
. If there is no next node, null
is returned.
Examples
The following example displays all the books in the XML document.
#using <System.Xml.dll>
using namespace System;
using namespace System::Xml;
int main()
{
XmlDocument^ doc = gcnew XmlDocument;
doc->Load( "books.xml" );
XmlNode^ currNode = doc->DocumentElement->FirstChild;
Console::WriteLine( "First book..." );
Console::WriteLine( currNode->OuterXml );
XmlNode^ nextNode = currNode->NextSibling;
Console::WriteLine( "\r\nSecond book..." );
Console::WriteLine( nextNode->OuterXml );
}
using System;
using System.Xml;
public class Sample4
{
public static void Main()
{
XmlDocument doc = new XmlDocument();
doc.Load("books.xml");
XmlNode currNode = doc.DocumentElement.FirstChild;
Console.WriteLine("First book...");
Console.WriteLine(currNode.OuterXml);
XmlNode nextNode = currNode.NextSibling;
Console.WriteLine("\r\nSecond book...");
Console.WriteLine(nextNode.OuterXml);
}
}
Imports System.Xml
public class Sample
public shared sub Main()
Dim doc as XmlDocument = new XmlDocument()
doc.Load("books.xml")
Dim currNode as XmlNode = doc.DocumentElement.FirstChild
Console.WriteLine("First book...")
Console.WriteLine(currNode.OuterXml)
Dim nextNode as XmlNode = currNode.NextSibling
Console.WriteLine(ControlChars.LF + "Second book...")
Console.WriteLine(nextNode.OuterXml)
end sub
end class
Applies to
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET