# XML parsing

**URL:** <https://discuss.elastic.co/t/xml-parsing/102836>\
**Category:** Logstash\
**Created:** [October 5, 2017, 12:16pm UTC](https://discuss.elastic.co/t/xml-parsing/102836 "2017-10-05T12:16:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![artobstrel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/artobstrel/32/16874_2.png) [@artobstrel](https://discuss.elastic.co/u/artobstrel)\
**Post date:** [October 5, 2017, 12:16pm UTC](https://discuss.elastic.co/t/xml-parsing/102836/1 "2017-10-05T12:16:38Z")

</div>

I will use the following XML document:

```
<data>
	<incident name="A">
		<records>
			<record rule="foo"></record>
		</records>
	</incident>
	<incident name="B">
		<records>
			<record rule="bar" severity="severe"></record>
				<record rule="CPU" severity="severe" duration="3000"></record>
				<record rule="RAM" severity="warning" duration="2000"></record>
			</record>
		</record>			
	</records>
	</incident>
</data>

```

After parsing I expecting get the following:

```
{"incident":"A","rule":"foo"}
{"incident":"B","rule":"bar", "severity":"severe"}
{"incident":"B","rule":"bar", "sub_rule":"CPU", "severity":"severe", "duration":"3000"}
{"incident":"B","rule":"bar", "sub_rule":"RAM", "severity":"warning", "duration":"2000"}

```

Please tell me how it's best done?

---

<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 2, 2017, 12:16pm UTC](https://discuss.elastic.co/t/xml-parsing/102836/2 "2017-11-02T12:16:58Z")

</div>

Closed on November 2, 2017, 12:16pm UTC

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