index_of method

index_of(child)

Returns the index of the specified child node in the child node array.

def index_of(self, child: aspose.words.Node):
    ...
ParameterTypeDescription
childNode

Remarks

Returns -1 if the node is not found in the child nodes.

Examples

Shows how to get the index of a given child node from its parent.

doc = aw.Document(file_name=MY_DIR + 'Rendering.docx')
body = doc.first_section.body
# Retrieve the index of the last paragraph in the body of the first section.
self.assertEqual(24, body.get_child_nodes(aw.NodeType.ANY, False).index_of(body.last_paragraph))

See Also