GetChildNodes

IStructuredDocumentTag.GetChildNodes method

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

public NodeCollection GetChildNodes(NodeType nodeType, bool isDeep)

Examples

Shows how to remove structured document tag, but keeps content inside.

Document doc = new Document(MyDir + "Structured document tags.docx");

// This collection provides a unified interface for accessing ranged and non-ranged structured tags. 
IEnumerable<IStructuredDocumentTag> sdts = doc.Range.StructuredDocumentTags.ToList();
Assert.That(sdts.Count(), Is.EqualTo(5));

// Here we can get child nodes from the common interface of ranged and non-ranged structured tags.
foreach (IStructuredDocumentTag sdt in sdts)
    if (sdt.GetChildNodes(NodeType.Any, false).Count > 0)
        sdt.RemoveSelfOnly();

sdts = doc.Range.StructuredDocumentTags.ToList();
Assert.That(sdts.Count(), Is.EqualTo(0));

See Also