//div[@id='..' and @class='...]
should do the trick. That's selecting the div
operators that have both attributes of the required value.
It's worth using one of the online XPath testbeds to try stuff out.
or //div[@id='id-74385'][@class='guest clearfix']
Adding to Brian Agnew's answer.
You can also do //div[@id='..' or @class='...]
and you can have parenthesized expressions inside //div[@id='..' and (@class='a' or @class='b')]
.
Sample XML:
<X>
<Y ATTRIB1=attrib1_value ATTRIB2=attrib2_value/>
</X>
string xPath="/" + X + "/" + Y +
"[@" + ATTRIB1 + "='" + attrib1_value + "']" +
"[@" + ATTRIB2 + "='" + attrib2_value + "']"
XPath Testbed: http://www.whitebeam.org/library/guide/TechNotes/xpathtestbed.rhtm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With