# Convert a hash map to array in order to split into multiple events

**URL:** <https://discuss.elastic.co/t/convert-a-hash-map-to-array-in-order-to-split-into-multiple-events/119529>\
**Category:** Logstash\
**Created:** [February 12, 2018, 5:59pm UTC](https://discuss.elastic.co/t/convert-a-hash-map-to-array-in-order-to-split-into-multiple-events/119529 "2018-02-12T17:59:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![antonis.mandilas](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@antonis.mandilas](https://discuss.elastic.co/u/antonis.mandilas)\
**Post date:** [February 12, 2018, 5:59pm UTC](https://discuss.elastic.co/t/convert-a-hash-map-to-array-in-order-to-split-into-multiple-events/119529/1 "2018-02-12T17:59:10Z")

</div>

Hello all,

In my use case I have an XML file that contains elements that I have to convert to array of objects. Example:

```
<root>
 <entry first_a="a" second_a="b" first_b="c" second_b="d"/>
</root>

```

using the xml filter and multiple xpaths

```
xpath => ["//entry/first_a/text()", "result[0]first", "//entry/second_a/text()", "result[0]second"]
xpath => ["//entry/first_b/text()", "result[1]first", "//entry/second_b/text()", "result[1]second"]

```

I have managed to convert it to and object with the structure

```
"result" {
   "0" => {
        first => ["a"],
        second=> ["b"]
    },
   "1" => {
        first => ["c"],
        second=> ["d"]
    }
}

```

If i try to perform a split on "result", so I can handle the different result events, but I am getting an error that split only can handled array types.

I would like to convert this hash map to an array or directly put values from xpath to an array of objects.

I tried to convert the hashmap using a ruby filter but I didn't manage to.

Could you help me to transform the map to an array?

Thanks in advance,  
Antony

---

<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:** [March 12, 2018, 5:59pm UTC](https://discuss.elastic.co/t/convert-a-hash-map-to-array-in-order-to-split-into-multiple-events/119529/2 "2018-03-12T17:59:38Z")

</div>

Closed on March 12, 2018, 5:59pm UTC

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