# Dealing with repeating XML fields

**URL:** <https://discuss.elastic.co/t/dealing-with-repeating-xml-fields/152114>\
**Category:** Logstash\
**Created:** [October 11, 2018, 7:15pm UTC](https://discuss.elastic.co/t/dealing-with-repeating-xml-fields/152114 "2018-10-11T19:15:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rcoundon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rcoundon/32/30010_2.png) [@rcoundon](https://discuss.elastic.co/u/rcoundon)\
**Post date:** [October 11, 2018, 7:15pm UTC](https://discuss.elastic.co/t/dealing-with-repeating-xml-fields/152114/1 "2018-10-11T19:15:15Z")

</div>

Hi

I have XML in the following format:

```
<appointments>
  <appointment>
    <Field name="Route Date">2018-10-10</Field>
    <Field name="Route ID">2296</Field>
    <Field name="Activity ID">1234</Field>
    <Field name="Master Activity ID" />
    <Field name="property_131" />
    <Field name="property_134" />
   </appointment>
   <appointment>
     <Field name="Route Date">2018-10-10</Field>
     <Field name="Route ID">2796</Field>
     <Field name="Activity ID">7233</Field>
     <Field name="Master Activity ID" />
     <Field name="property_131" />
     <Field name="property_134" />
    </appointment>
   </appointments>

```

I'd like to be able to do a few things with this:

Ignore the elements where name="property\*"  
Take the data from the element and the value from the name attribute to create an output that looks like:

```
    {
        "Route Date": "2018-10-10",
        "Route ID": "2296",
        "Activity ID": "1234",
    },
    {
        "Route Date": "2018-10-10",
        "Route ID": "2796",
        "Activity ID": "7233",
    }

```

I've managed to pull out the attribute name using the following xpath in the xml filter:  
`/appointments/appointment/Field[not(starts-with(@name, 'property'))]/text()", "field"`  
but I can't get my head around dealing with building the JSON that I need. Can anyone provide any pointers?  
Cheers

---

<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:** [November 8, 2018, 7:15pm UTC](https://discuss.elastic.co/t/dealing-with-repeating-xml-fields/152114/2 "2018-11-08T19:15:16Z")

</div>

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