Partager via


XMLNode.NextSibling Property

Gets a Microsoft.Office.Interop.Word.XMLNode object that represents the next Microsoft.Office.Interop.Word.XMLNode object in the document that is at the same level as the Microsoft.Office.Tools.Word.XMLNode control.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

Syntax

'Declaration
ReadOnly Property NextSibling As XMLNode
XMLNode NextSibling { get; }

Property Value

Type: Microsoft.Office.Interop.Word.XMLNode
A Microsoft.Office.Interop.Word.XMLNode control that represents the next element in the document that is at the same level as the specified element.

Remarks

If the specified element is the last element in the Microsoft.Office.Tools.Word.XMLNodes collection at this level, this property returns nulla null reference (Nothing in Visual Basic).

Examples

The following code example uses the PreviousSibling and NextSibling properties to display the names of the elements before and after an XMLNode control. This example assumes that the current document contains an XMLNode named CustomerFirstNameNode.

Private Sub DisplaySiblings()

    ' Display the previous sibling, if one exists. 
    If Not (Me.CustomerFirstNameNode.PreviousSibling Is Nothing) Then
        MsgBox("The previous sibling of '" & _
            Me.CustomerFirstNameNode.BaseName & "' is  '" & _
            Me.CustomerFirstNameNode.PreviousSibling.BaseName & "'.")
    Else
        MsgBox("'" & Me.CustomerFirstNameNode.BaseName & _
            "' is the first node in its hierarchy.")
    End If 

    ' Display the next sibling, if one exists. 
    If Not (Me.CustomerFirstNameNode.NextSibling Is Nothing) Then

        MsgBox("The next sibling of '" & _
            Me.CustomerFirstNameNode.BaseName & "' is '" & _
            Me.CustomerFirstNameNode.NextSibling.BaseName & "'.")
    Else
        MsgBox("'" & Me.CustomerFirstNameNode.BaseName & _
            "' is the last node in its hierarchy.")
    End If 
End Sub
private void DisplaySiblings()
{
    // Display the previous sibling, if one exists. 
    if (this.CustomerFirstNameNode.PreviousSibling != null)
    {
        MessageBox.Show("The previous sibling of '" +
            this.CustomerFirstNameNode.BaseName + "' is  '" +
            this.CustomerFirstNameNode.PreviousSibling.BaseName +
            "'.");
    }
    else
    {
        MessageBox.Show("'" + this.CustomerFirstNameNode.BaseName +
            "' is the first node in its hierarchy.");
    }

    // Display the next sibling, if one exists. 
    if (this.CustomerFirstNameNode.NextSibling != null)
    {

        MessageBox.Show("The next sibling of '" +
            this.CustomerFirstNameNode.BaseName + "' is '" +
            this.CustomerFirstNameNode.NextSibling.BaseName +
            "'.");
    }
    else
    {
        MessageBox.Show("'" + this.CustomerFirstNameNode.BaseName +
            "' is the last node in its hierarchy.");
    }
}

.NET Framework Security

See Also

Reference

XMLNode Interface

Microsoft.Office.Tools.Word Namespace