CompositeNodeChildNodes Property
Gets all immediate child nodes of this node.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.11
Syntax
public NodeCollection ChildNodes { get; }

Property Value

Type: NodeCollection
Remarks

Note, ChildNodes is equivalent to calling GetChildNodes(NodeType.Any, false) and creates and returns a new collection every time it is accessed.

If there are no child nodes, this property returns an empty collection.

Examples
Shows how to enumerate immediate children of a CompositeNode using the enumerator provided by the ChildNodes collection.
NodeCollection children = paragraph.ChildNodes;
foreach (Node child in children)
{
    // Paragraph may contain children of various types such as runs, shapes and so on.
    if (child.NodeType.Equals(NodeType.Run))
    {
        // Say we found the node that we want, do something useful.
        Run run = (Run) child;
        Console.WriteLine(run.Text);
    }
}
See Also