# Parsing complex xml

**URL:** <https://discuss.elastic.co/t/parsing-complex-xml/244271>\
**Category:** Logstash\
**Created:** [August 8, 2020, 10:14pm UTC](https://discuss.elastic.co/t/parsing-complex-xml/244271 "2020-08-08T22:14:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zmundo](https://avatars.discourse-cdn.com/v4/letter/z/46a35a/32.png) [@zmundo](https://discuss.elastic.co/u/zmundo)\
**Post date:** [August 8, 2020, 10:14pm UTC](https://discuss.elastic.co/t/parsing-complex-xml/244271/1 "2020-08-08T22:14:47Z")

</div>

I am working with cnc machine data reporting back in a complex xml structure.

![image](https://us1.discourse-cdn.com/elastic/original/3X/3/4/3433501a8389fc8e3ef43aa5e189e658871fe71c.png)

The data is only generated when the component changes value. If a machine sits ideal, things like the path component won't report any data, but components such as ambient temperature senors may still report data. Point being, everything under DeviceStream is dynamic.

I'm interested in drilling down to the lowest level of data, things like pathfeedrate, line, etc. I'm currently doing this with an ungodly amount of if statements and feel like there has to be a better way to parse this.

If you want to see the structure for yourself, there is a demo at [http://mtconnect.mazakcorp.com/](http://mtconnect.mazakcorp.com/)

---

<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:** [August 8, 2020, 11:30pm UTC](https://discuss.elastic.co/t/parsing-complex-xml/244271/2 "2020-08-08T23:30:55Z")

</div>

Parsing the XML is simple enough, an xml filter will do it. But you do not really explain what you want to do with the resulting data structure. What does "drilling down to" 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 5, 2020, 11:31pm UTC](https://discuss.elastic.co/t/parsing-complex-xml/244271/3 "2020-09-05T23:31:21Z")

</div>

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