Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Keeping XML structure with XML::Simple

by chazzz (Pilgrim)
on Jul 21, 2004 at 12:43 UTC ( #376226=note: print w/ replies, xml ) Need Help??


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.


Comment on Re^2: Keeping XML structure with XML::Simple
Download Code
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://376226]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2014-12-18 04:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (41 votes), past polls