Reputation: 203
Hi I have a xml data which i get from array of hashes and when I do a Dumper on it the output is as follows:
$var1=
'<Data>
<Data1>ABC</Data1>
<Data2>ABCD</Data2>
</Data>';
This I have in a variable call $var1. Now I am using XML::Simple
on it.. it is somewhat like: {Data1=>'ABC',Data2=>'ABCd'};
The first tag Data is gone. What is wrong?
Upvotes: 2
Views: 684
Reputation: 21517
Seems to be well-documented:
KeepRoot => 1
:In its attempt to return a data structure free of superfluous detail and unnecessary levels of indirection,
XMLin()
normally discards the root element name. Setting theKeepRoot
option to1
will cause the root element name to be retained. So after executing this code:$config = XMLin('<config tempdir="/tmp" />', KeepRoot => 1)
You'll be able to reference the tempdir as
"$config->{config}->{tempdir}"
instead of the default"$config->{tempdir}"
.
Upvotes: 7