XMLNode.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.
public:
property Microsoft::Office::Interop::Word::XMLNode ^ PreviousSibling { Microsoft::Office::Interop::Word::XMLNode ^ get(); };
public Microsoft.Office.Interop.Word.XMLNode PreviousSibling { get; }
member this.PreviousSibling : Microsoft.Office.Interop.Word.XMLNode
Public ReadOnly Property PreviousSibling As XMLNode
Property Value
A XMLNode object that represents the previous XMLNode object in the document that is at the same level as the XMLNode control.
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 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.");
}
}
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
Remarks
If the current Microsoft.Office.Interop.Word.XMLNode is the first element in the Microsoft.Office.Interop.Word.XMLNodes collection, this property returns null
.