http://www.perlmonks.org?node_id=376226


in reply to Re: Keeping XML structure with XML::Simple
in thread Keeping XML structure with XML::Simple

Are you happy that 'config' was replaced by 'opt'? If that is not the desired behaviour, instead write,
my $xml = XMLin(..., KeepRoot => 1); print XMLout($xml, KeepRoot => 1);
which would correctly output:
<config ip="127.0.0.1" port="12345">
  <timeout>1000</timeout>
  <timeout>2000</timeout>
</config>
The KeepRoot option tells XML::Simple that your structure already has a root node.

Replies are listed 'Best First'.
Re^3: Keeping XML structure with XML::Simple
by johnnywang (Priest) on Jul 21, 2004 at 16:44 UTC
    Just want to point out that the <timeout> element did not get fold up into attributes in your example is because there are more than one of them, by default if there is only one <timeout>, it will be folded up into an attribute.