Find text, get Xpath of containing element
Posted: Fri Jan 30, 2009 4:59 am
Greetings,
I need to obtain the Xpath of each element that contains a particular search string.
Here's a sample XML file:
I want to be able to search for the string "employer and location" and get back the Xpath of each of the three paragraphs that contain that string.
I would be most grateful for any help you can offer here.
Best regards,
Karl Forsyth
I need to obtain the Xpath of each element that contains a particular search string.
Here's a sample XML file:
Code: Select all
<table>
<tablerow>
<tablecell>
<par>Name of employer and location:</par>
</tablecell>
<tablecell>
<par>Jack Spratt Industries</par>
<par>123 E. West Road</par>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<par>Name of employer and location:</par>
</tablecell>
<tablecell>
<par>Red Robin Amalgamated</par>
<par>123 W. East Road</par>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<par>Name of employer and location:</par>
</tablecell>
<tablecell>
<par>Wicked Witch Ltd.</par>
<par>123 Yellow Brick Road</par>
</tablecell>
</tablerow>
</table>
I would be most grateful for any help you can offer here.
Best regards,
Karl Forsyth