i would like to select element, that has few childs with specific values. Here is example of xml: `
<events>
<event>
<startDateTime>2012-12-0128090</startDateTime>
<homeTeam>
<name>TEST123</name>
</homeTeam>
</event>
</events>`
Result i want is event, that contains startDateTime with value 2012-12-01 and contains TEST value of homeTeam/Name.
I am trying like this:
//events/event[startDateTime[contains(.,'2012-12-01')] and homeTeam/name[contains(.,'TEST')]]');
This returns me also events with starDateTime different from specified.
Thanks in advance.
I tweaked your XML and XPath slightly
<events>
<event>
<startDateTime>2012-12-0128090</startDateTime>
<homeTeam>
<name>TEST123</name>
</homeTeam>
</event>
<event>
<startDateTime>*2013-12-0128090*</startDateTime>
<homeTeam>
<name>TEST123</name>
</homeTeam>
</event>
</events>
I then used the following XPath to access the second node:
//events/event[(startDateTime[contains(.,'2013-12-01')]) and (homeTeam/name[contains(.,'TEST')])]
I also tested it with different name values, and it seems to work fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.