5番目の子と混同しないようにtable
、5番目のテーブルの奥深くにあるすべての要素を取得する必要があるhtmlドキュメントがあります。私の問題は、この5つの深層構造が任意の数の要素でラップされる可能性があるため、次のような絶対パスを使用できないことです。DOM
table
table
div
/ html / body / table / tbody / tr / td / table / tbody / tr / td / table / tbody / tr / td / table / tbody / tr / td / table
例えば:
<body>
<table>
<table>
<table>
<table>
<!--Grab this one -->
<table>
</table>
</table>
</table>
</table>
</table>
</body>
またはこれ:
<body>
<div> <!--Could be wrapped more than just once though -->
<table>
<table>
<table>
<table>
<!--Grab this one -->
<table>
</table>
</table>
</table>
</table>
</table>
</div>
</body>