问题
Can someone please provide me the xml query for retrieving the value of sessionId from the below response:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:createUserResponse xmlns:ns2="http://www.musicthp.com"
isNewUser="false"
profileId="32109"
sessionId="ryIlb+E5yj7FReA2w96uag=="
success="true">
<duration>316</duration>
</ns2:createUserResponse>
I tried using /ns2:createUserResponse/@sessionId and seems its not returning anything. I want to use this query in the XPATH extractor of jmeter. My requirement: I need to retrieve sessionId value using xpath extractor and use that value in the successive requests.
Thanks for your help in advance
回答1:
Have you set JMeter to use namespaces?
JMeter has been reported to have problems with namespaces. If fiddling with settings won't help, here is a workaround for the root element
/*/@sessionId
Workaround for any element in a namespace is to use *[local-name() = 'element']
instead of prefix:element
来源:https://stackoverflow.com/questions/6201472/xpath-query-for-xpath-extractor-of-jmeter