# Xpath pattern not working

**URL:** <https://discuss.elastic.co/t/xpath-pattern-not-working/99457>\
**Category:** Logstash\
**Created:** [September 5, 2017, 3:17pm UTC](https://discuss.elastic.co/t/xpath-pattern-not-working/99457 "2017-09-05T15:17:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [September 5, 2017, 3:17pm UTC](https://discuss.elastic.co/t/xpath-pattern-not-working/99457/1 "2017-09-05T15:17:05Z")

</div>

I am trying to parse SOAP messages using an XML filter. A SOAP message looks like this (all on one line)

```
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header><h:MyHeader xmlns:h="http://com.example/foo" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://com.example/foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<langId>en_US</langId>
</h:MyHeader>
</s:Header>
<s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<submit xmlns="http://com.example/bar"><sType><pRequest>
<iData xsi:type="q1:pData" xmlns="http://com.example/c/v1" xmlns:q1="http://com.example/bar">
<q1:document xsi:type="q2:ABC" xmlns:q2="http://com.example/p/v1">
<q2:pAmt>12345.00</q2:pAmt>
</q1:document></iData></pRequest></sType></submit></s:Body></s:Envelope>

```

I can parse most of the fields I want, I have an issue with getting the xsi:type out of the body. If I set remove\_namespaces to be false then using

> xpath =\> { "/s:Envelope/s:Body//q1:document/@xsi:type" =\> "type" }

I do not get type in the resulting message, nor do I get an error message (yes, all 5 namespaces are supplied to the xml filter). I think the syntax is correct because the PowerShell / .NET xpath implementation executes it and returns the expected attribute.

As a workaround I can set remove\_namespaces to be true and extract "/Envelope/Body//document/@xsi:type". It is non-obvious why the xsi prefix is required when remove\_namespaces is true.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 3, 2017, 3:17pm UTC](https://discuss.elastic.co/t/xpath-pattern-not-working/99457/2 "2017-10-03T15:17:09Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
