Share via


XMLNode.HasChildNodes Property (2007 System)

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

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

Syntax

'Declaration
Public ReadOnly Property HasChildNodes As Boolean
'Usage
Dim instance As XMLNode 
Dim value As Boolean 

value = instance.HasChildNodes
public bool HasChildNodes { get; }
public:
property bool HasChildNodes {
    bool get ();
}
public function get HasChildNodes () : boolean

Property Value

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

Examples

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 Sub DisplayFirstChildName()
    If Me.CustomerNode.HasChildNodes Then
        MsgBox("The first child of '" & Me.CustomerNode.BaseName & _
            "' is '" & Me.CustomerNode.FirstChild.BaseName & "'.")
    Else
        MsgBox("'" & Me.CustomerNode.BaseName & _
            "' has no child nodes.")
    End If 
End Sub
private void DisplayFirstChildName()
{
    if (this.CustomerNode.HasChildNodes)
    {
        MessageBox.Show("The first child of '" +
            this.CustomerNode.BaseName + "' is '" + 
            this.CustomerNode.FirstChild.BaseName + "'.");
    }
    else
    {
        MessageBox.Show("'" + this.CustomerNode.BaseName +
            "' has no child nodes.");
    }
}

.NET Framework Security

See Also

Reference

XMLNode Class

XMLNode Members

Microsoft.Office.Tools.Word Namespace