indexOf method

indexOf(node)

Returns the zero-based index of the specified node.

indexOf(node: Aspose.Words.Node)
ParameterTypeDescription
nodeNodeThe node to locate.

Remarks

This method performs a linear search; therefore, the average execution time is proportional to NodeCollection.count.

Returns

The zero-based index of the node within the collection, if found; otherwise, -1.

Examples

Shows how to get the index of a node in a collection.

let doc = new aw.Document(base.myDir + "Tables.docx");

let table = doc.firstSection.body.tables.at(0);
let allTables = doc.getChildNodes(aw.NodeType.Table, true);

expect(allTables.indexOf(table)).toEqual(0);

let row = table.rows.at(2);

expect(table.indexOf(row)).toEqual(2);

let cell = row.lastCell;

expect(row.indexOf(cell)).toEqual(4);

See Also