# Using XPath to Create Field Names

**URL:** <https://discuss.elastic.co/t/using-xpath-to-create-field-names/233892>\
**Category:** Logstash\
**Created:** [May 22, 2020, 11:07am UTC](https://discuss.elastic.co/t/using-xpath-to-create-field-names/233892 "2020-05-22T11:07:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jordan\_Muncaster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jordan_muncaster/32/45777_2.png) [@Jordan\_Muncaster](https://discuss.elastic.co/u/Jordan_Muncaster)\
**Post date:** [May 22, 2020, 11:07am UTC](https://discuss.elastic.co/t/using-xpath-to-create-field-names/233892/1 "2020-05-22T11:07:41Z")

</div>

Trying to use xpath to create the field name in a filter.

```auto
    filter {
      xml {
        source => "message"
        store_xml => false
        xpath => [
          "//XmlTag/text()",
           "//XmlTag/@name"
          ]
      }
    }

```

Is this something which is possible does anybody know?

---

<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:** [May 22, 2020, 2:18pm UTC](https://discuss.elastic.co/t/using-xpath-to-create-field-names/233892/2 "2020-05-22T14:18:11Z")

</div>

> [@Jordan\_Muncaster](#):
>
> Is this something which is possible does anybody know?

I do not believe this is supported.

---

<div class="post-metadata">

**Author:** ![Jordan\_Muncaster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jordan_muncaster/32/45777_2.png) [@Jordan\_Muncaster](https://discuss.elastic.co/u/Jordan_Muncaster)\
**Post date:** [May 22, 2020, 2:38pm UTC](https://discuss.elastic.co/t/using-xpath-to-create-field-names/233892/3 "2020-05-22T14:38:35Z")

</div>

Ah okay, thank you for your reply. Is there a solution to this issue using another filter type? e.g. getting your field name from the data that is parsed?

---

<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:** [May 22, 2020, 3:24pm UTC](https://discuss.elastic.co/t/using-xpath-to-create-field-names/233892/4 "2020-05-22T15:24:00Z")

</div>

Well, you could use a ruby filter to add a field based on the value of another field.

```
ruby { code => 'event.set( event.get("fieldContainingFieldName"), event.get("fieldContainingFieldValue") )' }
```

---

<div class="post-metadata">

**Author:** ![Jordan\_Muncaster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jordan_muncaster/32/45777_2.png) [@Jordan\_Muncaster](https://discuss.elastic.co/u/Jordan_Muncaster)\
**Post date:** [May 22, 2020, 3:28pm UTC](https://discuss.elastic.co/t/using-xpath-to-create-field-names/233892/5 "2020-05-22T15:28:05Z")

</div>

I'm not too familiar with this type of filter, so I'll go get researching.

Thank you very much for your help Badger!

---

<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:** [June 19, 2020, 3:28pm UTC](https://discuss.elastic.co/t/using-xpath-to-create-field-names/233892/6 "2020-06-19T15:28:11Z")

</div>

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