XPath to locate a cell with specific text parsing HTML tables
Use this XPath:
//td[contains(., 'Chapter')]
You want all td
s under your current node -- not - all in the document as the currently accepted answer selects.
Use:
.//td[.//text()[contains(., 'Chapter')]]
This selects all td
descendants of the current node that are named td
that have at least one text node descendant, whose string value contains the string "Chapter"
.
If it is known in advance that any td
under this table
only has a single text node, this can be simplified to just:
.//td[contains(., 'Chapter')]