I got html code like the following:
<p style="margin:0 0 0.5em 0;"><b>Blablub</b></p>
<table> ... </table>
Now I want to query the content of the <b> right above the table but only if the table does not have any attributes. I tried the following query:
//table[not(@*)]/preceding-sibling::p/b
If I remove the preceding-sibling::p/b part entirely it works. It gives me exactly the tables I need. However, if I use this query it gives me content of an <b> tag which precedes a table WITH attributes.
Use:
This means: Select all
belements that are children of allpelements that are the first preceding sibling of atablethat has no attributes.This is quite different from the problematic expression cited in the question:
The latter selects the
bchildren of the firstpfollowing sibling — there is no guarantee that the firstpfollowing sibling is also the first element sibling.