http://www.perlmonks.org?node_id=787993


in reply to A data structure for XML generation

It would complicate your parsing a bit, but I think you could have an even simpler format by omitting an extra layer of array for sibling nodes (just use them for children). The structure translation would still be unambiguous.

[ family => { name => 'Kawasaki' }, [ father => 'Yasushisa' , mother => { hair => 'short'} => 'Chizuko' , children => [ girl => 'Shiori', boy => { hair => 'black' } => 'Yasuke', boy => 'Kairi' ] ] ]
<family name="Kawasaki"> <father>Yasuhisa</father> <mother hair="short">Chizuko</mother> <children> <girl>Shiori</girl> <boy hair="black">Yusuke</boy> <boy>Kairi</boy> </children> </family>