public void CalcuateDepthOfNestedTables()
{
Document doc = new Document(MyDir + "Table.NestedTables.doc");
int tableIndex = 0;
foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
{
// First lets find if any cells in the table have tables themselves as children.
int count = GetChildTableCount(table);
Console.WriteLine("Table #{0} has {1} tables directly within its cells", tableIndex, count);
// Now let's try the other way around, lets try find if the table is nested inside another table and at what depth.
int tableDepth = GetNestedDepthOfTable(table);
if (tableDepth > 0)
Console.WriteLine("Table #{0} is nested inside another table at depth of {1}", tableIndex, tableDepth);
else
Console.WriteLine("Table #{0} is a non nested table (is not a child of another table)", tableIndex);
tableIndex++;
}
}