Reputation: 5048
I got this XML:
<iet:aw-data>
<iet:metadata filter=""/>
<iet:message-resource>
<iet:message>תוכניות אחרות שאינן פדראליים</iet:message>
<iet:customer id="1"/>
<iet:code>edi.claimfilingindicator.11</iet:code>
<iet:locale>iw_IL</iet:locale>
</iet:message-resource>
<iet:message-resource>
<iet:message>ספק מועדף הארגון (PPO)</iet:message>
<iet:customer id="1"/>
<iet:code>edi.claimfilingindicator.12</iet:code>
<iet:locale>iw_IL</iet:locale>
</iet:message-resource>
.
.
.
</iet:aw-data>
I want to build an expression to get all the nodes with code
and message
which contains a given parameter for each one of them.
What I made so far is this expression:
String exp = "//*[local-name()='message-resource']//*[local-name()='code'][contains(text(), 'edi')]"
Now I want to add the message
field as another condition to this expression and I need help with that.
Upvotes: 0
Views: 88
Reputation: 1523
My version
//*[local-name()='message-resource']/*[local-name()='code' and contains(text(), 'edi')]/../*[local-name()='message' and contains(text(), 'PPO')]/..
Just replace 'PPO' to what you are searching for in message.
Upvotes: 0
Reputation: 2632
You can use a subpath as a predicate. Assume you want to select code
s of message resources where message
contains 'some message substring':
//*[local-name()='message-resource' and ./*[local-name()='message' and contains(text(), 'some message substring')]]//*[local-name()='code'][contains(text(), 'edi')]
Upvotes: 2