XMLNode.ChildNodes Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
public:
property Microsoft::Office::Interop::Word::XMLNodes ^ ChildNodes { Microsoft::Office::Interop::Word::XMLNodes ^ get(); };
public Microsoft.Office.Interop.Word.XMLNodes ChildNodes { get; }
member this.ChildNodes : Microsoft.Office.Interop.Word.XMLNodes
Public ReadOnly Property ChildNodes As XMLNodes
Property Value
A 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 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.");
}
}
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