Reputation: 31
I am trying to extract a particular Xpath from a returned XML response on Jmeter.
Sample Response XML:
<?xml version="1.0" encoding="UTF-8"?>
<Responses>
<Rate href="http://test.com/psi?attribute1=x&attribute2=y">
<Cost currency='USD'>10</Cost>
</Rate>
</Responses>
I am using http://codebeautify.org/Xpath-Tester# to obtain the XPATH. I need the cost "10". I am looking at Xpath - //Responses/Rate/Cost/text() but this returns blank value. Now I update my XML to (Note: Removed the href part):
<?xml version="1.0" encoding="UTF-8"?>
<Responses>
<Rate>
<Cost currency='USD'>10</Cost>
</Rate>
</Responses>
The same XPATH //Responses/Rate/Cost/text() now returns "Text = 10". Any idea what problem the href is causing?
Upvotes: 0
Views: 768
Reputation: 31
Thanks all for the suggestions. The issue was with the framing of XPATH. There were multiple problems:
All in all, problem was wrong XPATH. Lesson learnt: Always check the xpath on freeformatter (or any other similar tool) before actually feeding into jmeter.
Upvotes: 1
Reputation: 34566
I tried your xml and JMeter gives me:
Assertion failure message: The reference to entity "attribute2" must end with the ';' delimiter. See log file for further details.
And log contains:
2015/07/08 10:46:26 ERROR - jmeter.util.XPathUtil: Type=Val=false Tol=false org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 107; The reference to entity "attribute2" must end with the ';' delimiter.
2015/07/08 10:46:26 WARN - jmeter.extractor.XPathExtractor: SAXException while processing (//Responses/Rate/Cost/) The reference to entity "attribute2" must end with the ';' delimiter.
So you issue is due to wrong XML, you should have:
<?xml version="1.0" encoding="UTF-8"?>
<Responses>
<Rate href="http://test.com/psi?attribute1=x&attribute2=y">
<Cost currency='USD'>10</Cost>
</Rate>
</Responses>
Upvotes: 1