Udostępnij za pośrednictwem


XMLNode.PreviousSibling Property (2007 System)

Gets a XMLNode object that represents the previous 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.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property PreviousSibling As XMLNode
'Usage
Dim instance As XMLNode 
Dim value As XMLNode 

value = instance.PreviousSibling
[BrowsableAttribute(false)]
public XMLNode PreviousSibling { get; }
[BrowsableAttribute(false)]
public:
property XMLNode^ PreviousSibling {
    XMLNode^ get ();
}
public function get PreviousSibling () : XMLNode

Property Value

Type: XMLNode
A XMLNode object that represents the previous XMLNode object in the document that is at the same level as the Microsoft.Office.Tools.Word.XMLNode control.

Remarks

If the current XMLNode is the first element in the XMLNodes collection, 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 Class

XMLNode Members

Microsoft.Office.Tools.Word Namespace