Reputation: 69
I'm not quite able to figure out how to match both of these cases below with one XPath I've tried searching on wildcard matching but not seeming to find it. Is it possible to match both cases below with just one XPath or are 2 needed?
Sometimes it is like this:
tr[@id='someid']/td/ol/li[1]/span/strong/a
Other times just this:
tr[@id='someid']/td/ol/li[1]/a
Upvotes: 1
Views: 355
Reputation: 940
By using
tr[@id='someid']/td/ol/li[1]/span/strong/a | tr[@id='someid']/td/ol/li[1]/a
you can select both paths in one query.
If you want all /a
-Elements under .../li[1]
, you can also use
tr[@id='someid']/td/ol/li[1]//a
(Note the double slash at the end). Source: W3Schools
Upvotes: 2
Reputation: 2998
XPath 1:
tr[@id='someid']/td/ol/li[1]/a | tr[@id='someid']/td/ol/li[1]/span/strong/a
XPath 2:
tr[@id='someid']/td/ol/li[1]/(a | span/strong/a)
Upvotes: 2