XMLNode.HasChildNodes Property

Gets a value that indicates whether the XMLNode control has child elements.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

bool HasChildNodes { get; }

Property Value

Type: System.Boolean
true if the XMLNode control has child elements; otherwise, false.

The following code example uses the FirstChild property to display the name of the first child node of an XMLNode control. The example also uses the HasChildNodes property to determine whether the XMLNode control has any child nodes. This example assumes that the current document contains an XMLNode named CustomerNode.

private void DisplayFirstChildName()
    if (this.CustomerNode.HasChildNodes)
        MessageBox.Show("The first child of '" +
            this.CustomerNode.BaseName + "' is '" + 
            this.CustomerNode.FirstChild.BaseName + "'.");
        MessageBox.Show("'" + this.CustomerNode.BaseName +
            "' has no child nodes.");

Community Additions