Share via


DocumentBase.XMLNodes 屬性

取得 Microsoft.Office.Interop.Word.XMLNodes 集合,表示文件中所有 XML 項目的集合。

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

語法

'宣告
Public ReadOnly Property XMLNodes As XMLNodes
public XMLNodes XMLNodes { get; }

屬性值

型別:Microsoft.Office.Interop.Word.XMLNodes
Microsoft.Office.Interop.Word.XMLNodes 集合,表示文件中所有 XML 項目的集合。

範例

下列程式碼範例會顯示文件中每個 Microsoft.Office.Interop.Word.XMLNodes 物件的名稱。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

Private Sub DocumentXMLNodes()
    Dim stringBuilder1 As New System.Text.StringBuilder()

    ' Add all of the node names to the StringBuilder.
    Dim node As Word.XMLNode
    For Each node In Me.XMLNodes
        stringBuilder1.Append(node.BaseName & ", ")
    Next node

    ' End the StringBuilder with a period.
    stringBuilder1.Remove(stringBuilder1.Length - 2, 2)
    stringBuilder1.Append(".")

    MessageBox.Show("The document contains " & Me.XMLNodes.Count.ToString() _
        & " node(s): " & stringBuilder1.ToString())
End Sub 
private void DocumentXMLNodes()
{
    System.Text.StringBuilder stringBuilder1 =
        new System.Text.StringBuilder();

    // Add all of the node names to the StringBuilder.
    foreach (Word.XMLNode node in this.XMLNodes)
    {
        stringBuilder1.Append(node.BaseName + ", ");
    }

    // End the StringBuilder with a period.
    stringBuilder1.Remove(stringBuilder1.Length - 2, 2);
    stringBuilder1.Append(".");

    MessageBox.Show("The document contains " +
        this.XMLNodes.Count.ToString() + " node(s): " +
        stringBuilder1.ToString());
}

.NET Framework 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間