Reputation: 21
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> > > > <a:Passengers> > <a:Passenger> > <a:PaxID>Ynr92+G9wmewELJS5SyMUmb3XHEefPUif4OXTIstk3N3yvtldxscrvgvygd9QHlH</a:PaxID> > <a:PersonOrgId>80553253</a:PersonOrgId> > <a:Ptc>ADT </a:Ptc> > <a:PtcGroup>ADT </a:PtcGroup> > <a:PtcId>1</a:PtcId> > <a:RecordLocator/> > <a:RecordNum>1</a:RecordNum> > <a:RedressId>8778787878</a:RedressId> > <a:ResSegStatus>4</a:ResSegStatus> > <a:Row>22</a:Row> > <a:Seat>B</a:Seat> > <a:Services xmlns:b="charges.radixx.com/v1"> > <b:Charge> > <b:Amount>0</b:Amount> > </a:Passenger> > </a:Passengers> > > > </s:Body> </s:Envelope>
Want to extract the Xpath of PaxID with Amount ='0' Here condition is in next node parallel to PaxID in a child node.
Xpath ://Passengers/Passenger/Services/Charge[1][Amount='0']/PaxID tried but not worked. Please help me xpath Query
Upvotes: 2
Views: 29
Reputation: 4834
NAMESPACES As a work-round for namespace limitations of the Xalan XPath parser (implementation on which JMeter is based) you need to: provide a Properties file (if for example your file is named namespaces.properties) which contains mappings for the namespace prefixes: prefix1=http://foo.apache.org prefix2=http://toto.apache.org … reference this file in user.properties file using the property: xpath.namespace.config=namespaces.properties
First lets make your xml-file valid like this
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<d:RetrievePaxAndSeatsByFlightResponse xmlns:d="departurecontrol.YYZ.com/v1">
<d:RetrievePaxAndSeatsByFlightResult>
<a:Passengers xmlns:a="passengers.YYZ.com/v1">
<a:Passenger>
<a:PaxID>Ynr92+G9wmewELJS5SyMUmb3XHEefPUif4OXTIstk3N3yvtldxscrvgvygd9QHlH</a:PaxID>
<a:PersonOrgId>80553253</a:PersonOrgId>
<a:Ptc>ADT </a:Ptc>
<a:PtcGroup>ADT </a:PtcGroup>
<a:PtcId>1</a:PtcId>
<a:RecordLocator/>
<a:RecordNum>1</a:RecordNum>
<a:RedressId>8778787878</a:RedressId>
<a:ResSegStatus>4</a:ResSegStatus>
<a:Row>22</a:Row>
<a:Seat>B</a:Seat>
<a:Services>
<b:Charge xmlns:b="charges.radixx.com/v1">
<b:Amount>0</b:Amount>
</b:Charge>
</a:Services>
</a:Passenger>
</a:Passengers>
</d:RetrievePaxAndSeatsByFlightResult>
</d:RetrievePaxAndSeatsByFlightResponse>
</s:Body>
</s:Envelope>
And then create/change namespaces.properties
file with these entries:
s=http://schemas.xmlsoap.org/soap/envelope/
d=departurecontrol.YYZ.com/v1
a=passengers.YYZ.com/v1
b=charges.radixx.com/v1
And then use this XPath
//a:Passengers/a:Passenger[a:Services/b:Charge/b:Amount='0']/a:PaxID
Where we create a predicate on a:Passenger where a:Services/b:Charge/b:Amount='0'
Upvotes: 0