Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: slaven [...] rezic.de
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.08
Fixed in: (no value)



Subject: XMLin(XMLout(...)) not the same
Contrary to the documentation of XMLout ("If the resulting XML is parsed using XMLin() it will return a data structure equivalent to the original") the resulting data structure is not the same in the sample script above. Regards, Slaven
#!/usr/bin/perl -w # -*- perl -*- # # $Id: $ # Author: Slaven Rezic # # Copyright (C) 2003 Slaven Rezic. All rights reserved. # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # # Mail: slaven@rezic.de # WWW: http://www.rezic.de/eserte/ # use XML::Simple; use Data::Compare; $outdata = { data => { de => { ct => "bla" } } }; $outdata2 = XMLin(XMLout($outdata)); warn Compare($outdata, $outdata2); require Data::Dumper; print STDERR "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([$outdata,$outdata2],[])->Indent(1)->Useqq(1)->Dump; # XXX
Apologies for the incredibly slow turnaround on this ticket. The test script you supplied attempted to round-trip this data structure to XML and back to Perl: $outdata = { data => { de => { ct => "bla" } } }; The problem occurred due to the default setting of the KeyAttr option. I really don't recommend using the default value of KeyAttr and in this case the simplest solution would be to disable it completely: my $xs = XML::Simple->new(KeyAttr => {}); $outdata2 = $xs->XMLin($xs->XMLout($outdata)); Following this change to the test script, the data was round-tripped successfully. Having said that, XML::Simple will never be able to dump/restore arbitrary perl data structures. The documentation for the XMLout() function does list some caveats of the Perl to XML process and as a result of your report, I have clarified the wording and added a specific mention of the KeyAttr option. Thanks for your report and apologies again for my tardy response. Regards Grant
#!/usr/local/bin/perl -w use XML::Simple; use Data::Compare; my $xs = XML::Simple->new(KeyAttr => {}); $outdata = { data => { de => { ct => "bla" } } }; $outdata2 = $xs->XMLin($xs->XMLout($outdata)); warn Compare($outdata, $outdata2); require Data::Dumper; print STDERR "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([$outdata,$outdata2],[])->Indent(1)->Useqq(1)->Dump; # XXX