XMLNode.ChildNodes Property
Gets a Microsoft.Office.Interop.Word.XMLNodes collection that represents the child elements of an XMLNode control.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)
Syntax
'Declaration
ReadOnly Property ChildNodes As XMLNodes
XMLNodes ChildNodes { get; }
Property Value
Type: Microsoft.Office.Interop.Word.XMLNodes
A Microsoft.Office.Interop.Word.XMLNodes collection that represents the child elements of an XMLNode control.
Examples
The following code example uses the ChildNodes property to create a list of the names of all child nodes of an XMLNode control. It then displays the list in a message box. This example assumes that the current document contains an XMLNode named CustomerNode.
Private Sub DisplayChildNodes()
Dim childNodeNames As New System.Text.StringBuilder()
If Me.CustomerNode.HasChildNodes Then
childNodeNames.Append(Me.CustomerNode.BaseName & _
" has the children: ")
Dim childElement As Word.XMLNode
For Each childElement In Me.CustomerNode.ChildNodes
childNodeNames.Append(" " & childElement.BaseName)
Next childElement
MsgBox(childNodeNames.ToString())
Else
MsgBox("'" & Me.CustomerNode.BaseName & _
"' has no child nodes.")
End If
End Sub
private void DisplayChildNodes()
{
System.Text.StringBuilder childNodeNames =
new System.Text.StringBuilder();
if (this.CustomerNode.HasChildNodes)
{
childNodeNames.Append(this.CustomerNode.BaseName +
" has the children: ");
foreach (Word.XMLNode childElement in this.CustomerNode.ChildNodes)
{
childNodeNames.Append(" " + childElement.BaseName);
}
MessageBox.Show(childNodeNames.ToString());
}
else
{
MessageBox.Show("'" + this.CustomerNode.BaseName +
"' has no child nodes.");
}
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.