Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xpath: find a node that has a given attribute whose value contains a string

Is there an xpath way to find a node that has a given attribute whose value contains a given string?

For example I have an xml document and want to find a node where the address attribute contains the string Downing, so that I could find the following node:

<person name="blair" address="10 Downing St. London"/> 
like image 769
flybywire Avatar asked Mar 05 '09 13:03

flybywire


People also ask

How do you locate an element by partially comparing its attributes in XPath?

We can identify elements by partially comparing to its attributes in Selenium with the help of regular expression. In xpath, there is contains () method. It supports partial matching with the value of the attributes. This method comes as useful while dealing with elements having dynamic values in their attributes.

Can you use XPath expression used to select the target node and its values?

XPath assertion uses XPath expression to select the target node and its values. It compares the result of an XPath expression to an expected value. XPath is an XML query language for selecting nodes from an XML. Step 1 − After clicking Add Assertion, select Assertion Category – Property Content.


1 Answers

select="//*[contains(@address,'Downing')]" 
like image 62
vartec Avatar answered Oct 18 '22 10:10

vartec