共用方式為


XMLNode.PreviousSibling 屬性

取得 Microsoft.Office.Interop.Word.XMLNode 物件,代表文件中上一個 Microsoft.Office.Tools.Word.XMLNode 物件與 Microsoft.Office.Interop.Word.XMLNode 的控制項是相同等級。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word (在 Microsoft.Office.Tools.Word.dll 中)

語法

'宣告
ReadOnly Property PreviousSibling As XMLNode
    Get
XMLNode PreviousSibling { get; }

屬性值

型別:Microsoft.Office.Interop.Word.XMLNode
取得 Microsoft.Office.Interop.Word.XMLNode 物件,代表文件中上一個 Microsoft.Office.Tools.Word.XMLNode 物件與 Microsoft.Office.Interop.Word.XMLNode 的控制項是相同等級。

備註

如果目前的 Microsoft.Office.Interop.Word.XMLNodeMicrosoft.Office.Interop.Word.XMLNodes 集合中的第一個項目,則這個屬性會傳回 nullNull 參照 (即 Visual Basic 中的 Nothing)。

範例

下列程式碼範例會使用 PreviousSibling 和 NextSibling 屬性來顯示 XMLNode 控制項前後顯示項目的名稱, 此範例假設目前的文件包含名為 CustomerFirstNameNode 的 XMLNode

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 安全性

請參閱

參考

XMLNode 介面

Microsoft.Office.Tools.Word 命名空間