I am just trying to create the XML
use XML::Simple;
my %element = ( "a" => "10" ,
"b" => "20" ,);
my $xs = new XML::Simple();
my $ref = $xs->XMLin(%element);
my $xml = $xs->XMLout($ref);
print $xml;
What is wrong on this code ? ( This is got Resolved )
use XML::Simple;
my %element = ( "a" => "10" ,
"b" => "20" ,);
my $xs = new XML::Simple();
my $xml = $xs->XMLout(\%element);
print $xml;
This produces the following output:
<opt a="10" b="20" />
But what I'd really like to get is this:
<a> 10 </a>
<b> 20 </b>
How can I achieve this?
XMLin takes XML and transforms it into a Perl data structure.
XMLout takes a Perl data strcuture and transforms it to XML.
You are trying to feed a Perl data structure to XMLin and feed the result to XMLout.
Have you considered reading the documentation?
Update: The documentation (yes, we know it's boring) offers quite a lot of options that you can pass to XML::Simple::new()
. One of them is NoAttr => 1
. You might want to check that one out, but a look at the others (some of which are marked "important") won't hurt.