# Xml/xpath returning an array

**URL:** <https://discuss.elastic.co/t/xml-xpath-returning-an-array/96345>\
**Category:** Logstash\
**Created:** [August 8, 2017, 9:35pm UTC](https://discuss.elastic.co/t/xml-xpath-returning-an-array/96345 "2017-08-08T21:35:41Z")\
**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:** [August 8, 2017, 9:35pm UTC](https://discuss.elastic.co/t/xml-xpath-returning-an-array/96345/1 "2017-08-08T21:35:41Z")

</div>

I am trying to parse SOAP messages, which take the following form

`<Envelope><Header><foo>1</foo></Header><Body><bar>2</bar></Body></Envelope>`

I need to get the name of the first element of the Body, which I tried to do using

`xpath => { "local-name(/Envelope/Body/*[1])" => "requestType" }`

Sadly this returns an array, even when "force\_array =\> false" is set. I can extract the first element of the array using

`mutate { add_field => { requestType2 => "%{requestType[0]}" } }`

but I would like to know if there is a way to have local-name result in a string rather than an array.

---

<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:** [September 5, 2017, 9:35pm UTC](https://discuss.elastic.co/t/xml-xpath-returning-an-array/96345/2 "2017-09-05T21:35:53Z")

</div>

Closed on September 5, 2017, 9:35pm UTC

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