in reply to
XML::Simple isn't listening to SuppressEmpty
FWIW, I've experimented with
XML::Simple for a couple of hours now, and, as far as I can see, SuppressEmpty doesn't work in this situation. I get
the same results with or without it.
I triple-checked using
Data::Serializer::Raw,
Data::Dumper::Concise, and
XML::Dumper.
Also, I used
use XML::Simple qw(:strict), and I used
'content' instead of
'-content'. Here's what
I have so far:
#!/usr/bin/perl -l
use strict;
use warnings;
use Data::Dumper::Concise;
use Data::Serializer::Raw;
use XML::Simple qw(:strict);
my $file = '/root/Desktop/xml2.xml';
open my $xml, '<', $file or die $!;
binmode $xml, ":encoding(UTF-8)";
my $ref = XMLin(
$xml,
SuppressEmpty => undef,
KeyAttr => { set => 'name' },
ForceArray => [ 'set' ],
ContentKey => 'content',
);
my $xml_raw_serializer = Data::Serializer::Raw->new(
serializer => 'XML::Dumper'
);
my $xml_data = $xml_raw_serializer->serialize($ref);
print Dumper($xml_raw_serializer->deserialize($xml_data));
close $xml;