Needing some instructions on Xpath. I have something along the following lines in terms of HTML. How would I extract the table following the first paragraph with an image?
<p align="center">
<img src="some_image.gif" alt="Some Title">
</p>
<table width="500" border="1" class="textstyle" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="4" align="center">
<b>Label</b>
</td>
</tr>
<tr>
<td align="center">
Text
</td>
<td align="center">
Text
</td>
<td align="center">
Text
</td>
<td align="center">
Text
</td>
</tr>
</table>
<blockquote>
<p class="textstyle">
Text.
</p>
</blockquote>
Obviously I’d like to see how to write the xpath for this, however I would further like to understand my options via some kind of an abbreviated list / cheatsheet of what options exist for xpath. I was considering using something along the lines of this:
//table[preceding-sibling::p[contains(align(), "center")
or perhaps something that would allow me to say a p that’s centered with an img in it, however I’m just not sure where to go to get a nice comprehensive list vs an actual writeup that explains all the gory details.
Use:
This selects the
tablethat is the firsttable– following sibling of the firstpin the document that has animgchild.I recommend using the XPath Visualizer — a tool that has helped many thousands of people learn XPath the fun way.