XML parsing

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?

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