Write xpath for the node containing node value and attribute togetther

Rahul965

New Member
Suppose this is my XML:\[code\]<myxml> <data key="true">Apple</data> <data key="true">banana</data> <data1 key="true">banana</data1> <data>Apple</data></myxml>\[/code\]I need an XPath expression for the tag which contains attribute \[code\]key="true"\[/code\] and node value = http://stackoverflow.com/questions/10541576/\[code\]Apple\[/code\].I tried different combinations but not succeeded.
  • For attribute I use this \[code\]xpath="/myxml/data[@key='true']\[/code\]
  • and for Node value I use this \[code\]xpath = "/myxml/data[. ='Apple']/\[/code\]
  • and also try this \[code\]xpath = "/myxml/data[.='Apple'][@key='true]/\[/code\]
but got error.I have multiple tags in the xpath. \[code\]/mappings/mapping[data[@iskey='true'][.='apple'] and data1[@iskey='true'][.='banana']/\[/code\] There is a mistake in this path.How I specify both the attribute and node value together ?
 
Back
Top