CompositeNodeGetChildNodes Method

Returns a live collection of child nodes that match the specified type.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
public NodeCollection GetChildNodes(
	NodeType nodeType,
	bool isDeep


Type: Aspose.WordsNodeType
Specifies the type of nodes to select.
Type: SystemBoolean
True to select from all child nodes recursively. False to select only among immediate children.

Return Value

Type: NodeCollection
A live collection of child nodes of the specified type.

The collection of nodes returned by this method is always live.


A live collection is always in sync with the document. For example, if you selected all sections in a document and enumerate through the collection deleting the sections, the section is removed from the collection immediately when it is removed from the document.

Demonstrates how to remove a specified TOC from a document.
// Open a document which contains a TOC
Document doc = new Document(MyDir + "Table of contents.docx");

// Remove the first TOC from the document
Field tocField = doc.Range.Fields[0];

// Save the output
doc.Save(ArtifactsDir + "Field.RemoveTocFromDocument.docx");
Shows how to extract images from a document and save them as files.
public void ExtractImagesToFiles()
    Document doc = new Document(MyDir + "Images.docx");

    NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
    int imageIndex = 0;
    foreach (Shape shape in shapes.OfType<Shape>())
        if (shape.HasImage)
            string imageFileName =
            shape.ImageData.Save(ArtifactsDir + imageFileName);
See Also