# Converting XML key value pairs

**URL:** <https://discuss.elastic.co/t/converting-xml-key-value-pairs/61582>\
**Category:** Logstash\
**Created:** [September 27, 2016, 8:52am UTC](https://discuss.elastic.co/t/converting-xml-key-value-pairs/61582 "2016-09-27T08:52:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ydkadri](https://avatars.discourse-cdn.com/v4/letter/y/f07891/32.png) [@ydkadri](https://discuss.elastic.co/u/ydkadri)\
**Post date:** [September 27, 2016, 8:52am UTC](https://discuss.elastic.co/t/converting-xml-key-value-pairs/61582/1 "2016-09-27T08:52:57Z")

</div>

I have used Tika to convert a number of documents into XML. These documents contain metadata in the format

```
<meta name="Title" content="The Hobbit" />
<meta name="Author" content="Tolkein" />
<meta name="Creation-Date" content="1937-09-21" />

```

When I use logstash to read in this XML it splits each row into K:V pairs as

```
{"name": "Title", "content": "The Hobbit"},
...

```

however when I read this into Elasticsearch I would like to read it as

```
{"Title": "The Hobbit"},
...

```

Would I do this in Logstash or through the template file and how would I make this?

---

<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:** [September 27, 2016, 8:57am UTC](https://discuss.elastic.co/t/converting-xml-key-value-pairs/61582/2 "2016-09-27T08:57:37Z")

</div>

I believe you need to use a ruby filter for this. Unfortunately I don't have time to type up an example.

---

<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 6, 2017, 4:36am UTC](https://discuss.elastic.co/t/converting-xml-key-value-pairs/61582/3 "2017-07-06T04:36:42Z")

</div>


