# Always create fields defined by Xpath

**URL:** <https://discuss.elastic.co/t/always-create-fields-defined-by-xpath/78875>\
**Category:** Logstash\
**Created:** [March 16, 2017, 2:10pm UTC](https://discuss.elastic.co/t/always-create-fields-defined-by-xpath/78875 "2017-03-16T14:10:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcannell](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@jcannell](https://discuss.elastic.co/u/jcannell)\
**Post date:** [March 16, 2017, 2:10pm UTC](https://discuss.elastic.co/t/always-create-fields-defined-by-xpath/78875/1 "2017-03-16T14:10:11Z")

</div>

Hello,

I'm using the xml filter plugin in logstash. Specifically, I've been using the xpath setting to parse my xml data into fields.

I wanted to know if it's possible for logstash to create the field I've defined in xpath, even if it doesn't exist in the xml (i.e. it's an option xml element or attribute).

For instance, consider the following xpath  
`"/filter/meta/@requires", "requires"`

which places the requires xml attribute in the requires logstash field. However, I would like an empty requires logstash field created even if this attribute isn't present in the xml. I have a large set of elements/attributes in my xml that may or may not be present, so I'd like to do this the most efficient way possible.

Is there an xml filter setting that does this?

Thanks.

---

<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:** [April 13, 2017, 2:11pm UTC](https://discuss.elastic.co/t/always-create-fields-defined-by-xpath/78875/2 "2017-04-13T14:11:15Z")

</div>

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