共用方式為


XMLNode.ParentNode Property

Gets a Microsoft.Office.Interop.Word.XMLNode object that represents the parent element of the specified 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 ParentNode As XMLNode
XMLNode ParentNode { get; }

Property Value

Type: Microsoft.Office.Interop.Word.XMLNode
A Microsoft.Office.Interop.Word.XMLNode control that represents the parent element of the specified Microsoft.Office.Tools.Word.XMLNode object.

Remarks

For a root node, the ParentNode property returns nulla null reference (Nothing in Visual Basic).

Examples

The following code example uses the ParentNode property to display the name of the parent node of an XMLNode control. This example assumes that the current document contains an XMLNode named CustomerFirstNameNode.

Private Sub DisplayParentNode()
    MsgBox("The parent node of '" & Me.CustomerFirstNameNode.BaseName & _
        "' is '" & Me.CustomerFirstNameNode.ParentNode.BaseName & "'.")
End Sub
private void DisplayParentNode()
{
    MessageBox.Show("The parent node of '" +
        this.CustomerFirstNameNode.BaseName + "' is '" + 
        this.CustomerFirstNameNode.ParentNode.BaseName + "'.");
}

.NET Framework Security

See Also

Reference

XMLNode Interface

Microsoft.Office.Tools.Word Namespace