# XML filter, parse key

**URL:** <https://discuss.elastic.co/t/xml-filter-parse-key/146203>\
**Category:** Logstash\
**Created:** [August 27, 2018, 3:24pm UTC](https://discuss.elastic.co/t/xml-filter-parse-key/146203 "2018-08-27T15:24:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sebastian\_Herrera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebastian_herrera/32/53209_2.png) [@Sebastian\_Herrera](https://discuss.elastic.co/u/Sebastian_Herrera)\
**Post date:** [August 27, 2018, 3:24pm UTC](https://discuss.elastic.co/t/xml-filter-parse-key/146203/1 "2018-08-27T15:24:43Z")

</div>

Hi all, i am parsing a xml, my problem is that one of the kml key is having the action so i am wondering to save that key in one field is that possible?

```
<action >
     <ip></ip>
     <mac>asdasdreg</mac>
     <TimeStamp>2018-08-26T08:14:29-08:00</TimeStamp>
</action>

```

regards

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 27, 2018, 8:02pm UTC](https://discuss.elastic.co/t/xml-filter-parse-key/146203/2 "2018-08-27T20:02:03Z")

</div>

It's not clear to me what you're looking for. Could you give an example of the desired outcome?

---

<div class="post-metadata">

**Author:** ![Sebastian\_Herrera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebastian_herrera/32/53209_2.png) [@Sebastian\_Herrera](https://discuss.elastic.co/u/Sebastian_Herrera)\
**Post date:** [August 27, 2018, 8:08pm UTC](https://discuss.elastic.co/t/xml-filter-parse-key/146203/3 "2018-08-27T20:08:02Z")

</div>

> [@magnusbaeck](#):
>
> e what you're looking for. Could you give an example of the desired outcome

Yes. i have multiple xml logs supose that i have

```
<action >
 <ip></ip>
 <mac>asdasdreg</mac>
 <TimeStamp>2018-08-26T08:14:29-08:00</TimeStamp>

```

```
<action2 >
 <ip></ip>
 <mac>asdasdreg</mac>
 <TimeStamp>2018-08-26T08:14:29-08:00</TimeStamp>

```

the thing is that i want to parse the xml and then add a field with the action name (action or action2) in this example. Is that possible?

regards

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 27, 2018, 8:17pm UTC](https://discuss.elastic.co/t/xml-filter-parse-key/146203/4 "2018-08-27T20:17:42Z")

</div>

Hmm. I guess you'll have to use an xml filter with `store_xml => true` to parse the entire XML, then use a ruby filter to check what fields you got and store the name of one of the fields in another field.

---

<div class="post-metadata">

**Author:** ![Sebastian\_Herrera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebastian_herrera/32/53209_2.png) [@Sebastian\_Herrera](https://discuss.elastic.co/u/Sebastian_Herrera)\
**Post date:** [August 28, 2018, 12:35pm UTC](https://discuss.elastic.co/t/xml-filter-parse-key/146203/5 "2018-08-28T12:35:31Z")

</div>

> [@magnusbaeck](#):
>
> `e_xml => true` to parse the entire XML, then use a ruby filter to check what fields you got and store the name of one of the fields in another field.

i cant use the name here()?

regards

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 28, 2018, 2:13pm UTC](https://discuss.elastic.co/t/xml-filter-parse-key/146203/6 "2018-08-28T14:13:26Z")

</div>

I don't understand what you mean.

---

<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 25, 2018, 2:13pm UTC](https://discuss.elastic.co/t/xml-filter-parse-key/146203/7 "2018-09-25T14:13:33Z")

</div>

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