# How to parse XML using XPATH from SOAP

**URL:** <https://discuss.elastic.co/t/how-to-parse-xml-using-xpath-from-soap/236597>\
**Category:** Logstash\
**Created:** [June 11, 2020, 1:07am UTC](https://discuss.elastic.co/t/how-to-parse-xml-using-xpath-from-soap/236597 "2020-06-11T01:07:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vince.mar04](https://avatars.discourse-cdn.com/v4/letter/v/7cd45c/32.png) [@vince.mar04](https://discuss.elastic.co/u/vince.mar04)\
**Post date:** [June 11, 2020, 1:07am UTC](https://discuss.elastic.co/t/how-to-parse-xml-using-xpath-from-soap/236597/1 "2020-06-11T01:07:11Z")

</div>

Continuing the discussion from [How to parse XML using XPATH from SOAP API in Logstash](https://discuss.elastic.co/t/how-to-parse-xml-using-xpath-from-soap-api-in-logstash/223979/2):

in this part we mentioned this question, it was solved with /soapenv:Envelope/soapenv:Body/multiRef/metricValue/text() but in my case it doesn't work

---

<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:** [June 11, 2020, 2:00am UTC](https://discuss.elastic.co/t/how-to-parse-xml-using-xpath-from-soap/236597/2 "2020-06-11T02:00:29Z")

</div>

Please provide an example of your XML and tell us what you have already tried.

---

<div class="post-metadata">

**Author:** ![vince.mar04](https://avatars.discourse-cdn.com/v4/letter/v/7cd45c/32.png) [@vince.mar04](https://discuss.elastic.co/u/vince.mar04)\
**Post date:** [June 11, 2020, 3:06am UTC](https://discuss.elastic.co/t/how-to-parse-xml-using-xpath-from-soap/236597/3 "2020-06-11T03:06:20Z")

</div>

> [@Badger](#):
>
> Please provide an example of your XML and tell us what you have already tried.

I have the next xml.

\<not:notificar xmlns:env="[http://schemas.xmlsoap.org/soap/envelope/"](http://schemas.xmlsoap.org/soap/envelope/%22) xmlns:not1="example"\>  
not1:objetoR  
not1:resul02\</not1:resul\>  
not1:date20200603\</not1:date\>  
not1:diag999\</not1:diag\>  
\</not1:objetoR\>  
\</not:notificar\>

I want parse resul and date.

My logstash is

input {  
jdbc {  
type =\> "test"  
jdbc\_validate\_connection =\> true  
jdbc\_connection\_string =\> ""  
jdbc\_user =\> ""  
jdbc\_password =\> ""  
jdbc\_driver\_library =\> "/"  
jdbc\_driver\_class =\> "Java::oracle.jdbc.driver.OracleDriver"  
statement =\>"select campo\_xml from test)"  
}  
}  
filter {  
if [type] == "test" {  
xml{  
source =\> "test"  
store\_xml =\> false  
force\_array =\> false  
xpath =\> [  
"//inot1:objetoR/inot1:resul/text()", "resul",  
}  
}  
}  
output {  
if [type] == "test" {  
stdout{ codec =\> rubydebug {metadata =\> true}}

}  
}

---

<div class="post-metadata">

**Author:** ![Jenni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenni/32/29684_2.png) [@Jenni](https://discuss.elastic.co/u/Jenni)\
**Post date:** [June 11, 2020, 11:33am UTC](https://discuss.elastic.co/t/how-to-parse-xml-using-xpath-from-soap/236597/4 "2020-06-11T11:33:00Z")

</div>

The thread that you used as an example to solve this doesn't seem helpful to me, as I get the impression that the poster had a problem with attributes with namespaces and “solved” it by querying a completely different field without using those?

Please make sure to use the code formatting option (`</>`) to post code because otherwise it's not readable. Why do the names in your xpath begin with `inot1` instead of `not1`?

---

<div class="post-metadata">

**Author:** ![vince.mar04](https://avatars.discourse-cdn.com/v4/letter/v/7cd45c/32.png) [@vince.mar04](https://discuss.elastic.co/u/vince.mar04)\
**Post date:** [June 12, 2020, 4:02pm UTC](https://discuss.elastic.co/t/how-to-parse-xml-using-xpath-from-soap/236597/5 "2020-06-12T16:02:30Z")

</div>

> [@Jenni](#):
>
> The thread that you used as an example to solve this doesn't seem helpful to me, as I get the impression that the poster had a problem with attributes with namespaces and “solved” it by querying a completely different field without using those?
> 
> Please make sure to use the code formatting option ( `</>` ) to post code because otherwise it's not readable. Why do the names in your xpath begin with `inot1` instead of `not1` ?

Thank you.

The solution I applied was

remove\_namespaces =\> "true"

"//objetoR/resul/text()", "resul"

---

<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:** [July 10, 2020, 4:02pm UTC](https://discuss.elastic.co/t/how-to-parse-xml-using-xpath-from-soap/236597/6 "2020-07-10T16:02:34Z")

</div>

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