# Problems with xpath matching

**URL:** <https://community.gatling.io/t/problems-with-xpath-matching/545>\
**Category:** Gatling (Open-Source)\
**Created:** [August 18, 2013, 12:23pm UTC](https://community.gatling.io/t/problems-with-xpath-matching/545 "2013-08-18T12:23:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dino\_Fancellu](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@Dino\_Fancellu](https://community.gatling.io/u/Dino_Fancellu)\
**Post date:** [August 18, 2013, 12:23pm UTC](https://community.gatling.io/t/problems-with-xpath-matching/545/1 "2013-08-18T12:23:44Z")

</div>

Getting some XML back from a GET

Basically:

**xxx**

Please, don’t blame me for the messed up namespace on productid, not my XML.

However if I do

**check((xpath("//\*").saveAs(“stuff”))**

it gives me an error when it does the implicit exists

However it should work fine. That xpath (not the one I want but I just want to get SOMETHING to work) works fine in Oxygen in XPath 1.0 and 2.0 modes.  
As its so permissive.

Now, I can save the xml, e.g.

**bodyString.saveAs(“returned\_xml”)**

And can even print out as debug later on via **exec(session=\>session)**

How would I write my own check predicate? i.e. take xml string, perform various of my own xpath tests, emit an error to gatling if I’m not happy.

Thanks.

Dino.

---

<div class="post-metadata">

**Author:** ![Dino\_Fancellu](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@Dino\_Fancellu](https://community.gatling.io/u/Dino_Fancellu)\
**Post date:** [August 18, 2013, 12:25pm UTC](https://community.gatling.io/t/problems-with-xpath-matching/545/2 "2013-08-18T12:25:30Z")

</div>

Oh yes, using the latest Gatling 2.0.0.20130628

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [August 27, 2013, 10:36am UTC](https://community.gatling.io/t/problems-with-xpath-matching/545/3 "2013-08-27T10:36:42Z")

</div>

Gatling uses plain Java Xerces’ XPath, no custom stuff here.

Could you please provide a XML sample and XPath expression that look like your real world use case?  
You can try an online XPath tester such as this one: [http://www.freeformatter.com/xpath-tester.html](http://www.freeformatter.com/xpath-tester.html)

Also note that if you have namespaces in your XML, you have to pass them explicitly and also use them in your expression, like in the second sample here:  
[https://github.com/excilys/gatling/wiki/Checks#wiki-xpath](https://github.com/excilys/gatling/wiki/Checks#wiki-xpath)

Also note that you’re using an old timestamped version (June, 28) while M3a has been released on July, 10. You’d better upgrade.

Cheers,

Stéphane

---

<div class="post-metadata">

**Author:** ![Dino\_Fancellu](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@Dino\_Fancellu](https://community.gatling.io/u/Dino_Fancellu)\
**Post date:** [August 28, 2013, 12:34pm UTC](https://community.gatling.io/t/problems-with-xpath-matching/545/4 "2013-08-28T12:34:58Z")

</div>

Works now that I’ve upgraded to 2.0.0.M3a

Did a .check(xpath("//organisation-id").saveAs(“organisation-id”)) , works lovely.

Dino.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [August 28, 2013, 12:35pm UTC](https://community.gatling.io/t/problems-with-xpath-matching/545/5 "2013-08-28T12:35:53Z")

</div>

Great news!
