Undisputed007
Undisputed007

Reputation: 649

How can i get this value with XPATH in JMeter

I have a webservice response as such :

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
  <soap:Body>
     <FileResponse xmlns="http://xxx.x.sx.be">
        <id>090150e080249d09</id>
     </FileResponse>
  </soap:Body>
</soap:Envelope>

I am trying to extract the value of "id" but i can't seem to figure out the right query. I used an online generator which provided :

/soap:Envelope[@xmlns:soap="http://www.w3.org/2003/05/soap-envelope"]/soap:Body/FileResponse[@xmlns="http://xxx.x.sx.be"]/id/text()

But it doesn't seem to work in Jmeter as the response is always null.

Upvotes: 1

Views: 200

Answers (2)

Phil Blackburn
Phil Blackburn

Reputation: 1067

Your test for the namespace is invalid. Xpath queries do not support this.

Instead you will need to JMeter to pass in the namespaces declarations along with the xpath query. I dont know how JMeter does that but I can give you an xpath expression that may work around it.

//*[local-name()='FileResponse']/*[local-name()="id"]/text()

The xpath will test the name of the node and ignoring the namespaces. Its not recomended practice to test without namespaces and could be slow but it'll work.

Upvotes: 0

Undisputed007
Undisputed007

Reputation: 649

I found this to be the answer : //*[local-name() = 'id']

Upvotes: 1

Related Questions