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 命名空间