DocumentBase.XMLNodes 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个 XMLNodes 集合,该集合表示文档中所有 XML 元素的集合。
public Microsoft.Office.Interop.Word.XMLNodes XMLNodes { get; }
属性值
一个 XMLNodes 集合,表示文档中所有 XML 元素的集合。
示例
下面的代码示例显示文档中每个对象的名称 Microsoft.Office.Interop.Word.XMLNodes 。 若要使用此示例,请在 ThisDocument 文档级项目的类中运行它。
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());
}
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