Skip Menu |

This queue is for tickets about the XML-Simple CPAN distribution.

Report information
The Basics
Id: 11219
Status: resolved
Priority: 0/
Queue: XML-Simple

People
Owner: Nobody in particular
Requestors: petek [...] bsod.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 2.13
Fixed in: (no value)



Subject: XMLout loses elements in nested hash structure
XML::Simple 2.13 with XML::SAX 0.12 is giving an incorrect XML document back when called with XMLout. In this example, the "c" element is dropped: perl -MXML::Simple -e'$xs=XML::Simple->new; print $xs->XMLout({b => { c => { name => [ 'data' ], value => [ 'data' ] } } });'; Output: <opt> <b> <name>data</name> <value>data</value> </b> </opt> Removing the arrayrefs doesn't help: perl -MXML::Simple -e'$xs=XML::Simple->new; print $xs->XMLout({b => { c => { name => 'data', value => 'data' } } });'; Output: <opt> <b name="data" value="data" /> </opt> It may have something to do with hash keys named "name" and "value": perl -MXML::Simple -e'$xs=XML::Simple->new; print $xs->XMLout({b => { c => { d => [ 'data' ], e => [ 'data' ] } } });'; Output: <opt> <b name="c"> <d>data</d> <e>data</e> </b> </opt>
XML::Simple is working as designed. Array folding (on XMLin) and unfolding (on XMLout) is enabled by default. If you don't want it, you need to turn it off using the KeyAttr option: perl -MXML::Simple -e'$xs=XML::Simple->new(KeyAttr => []); print $xs->XMLout({b => { c => { name => [ 'data' ], value => [ 'data' ] } } });'; For more on KeyAttr, see this article: http://www.perlmonks.org/index.pl?node_id=218480 Regards Grant