in reply to XML::Smart - Development in final stage. (beta is out)
And the ouptut isuse strict; use XML::Simple; use Data::Dumper; my $xs = new XML::Simple(forcearray => 1, forcecontent => 1, contentkey => '_content', keyattr => []); my $xml; { local $/ = undef; $xml = <DATA>; } my $xmlHash = $xs->XMLin($xml); print "xmlHash:\n" . Dumper($xmlHash); __DATA__ <?xml version="1.0" encoding="iso-8859-1"?> <hosts> <server os="linux" type="redhat" version="8.0"> <address>192.168.0.1</address> <address>192.168.0.2</address> </server> <server address="192.168.2.100" os="linux" type="conectiva" version= +"9.0"/> </hosts>
Note that I force the '_content' key which assures that there'll be much less inconsistancy in the xml structure (HASHREF or ARRAYREF etc).xmlHash: $VAR1 = { 'server' => [ { 'os' => 'linux', 'address' => [ { '_content' => '192.168.0.1' }, { '_content' => '192.168.0.2' } ], 'version' => '8.0', 'type' => 'redhat' }, { 'os' => 'linux', 'address' => '192.168.2.100', 'version' => '9.0', 'type' => 'conectiva' } ] };
Robert Wilensky, University of California
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: XML::Smart - Development in final stage. (beta is out)
by gmpassos (Priest) on May 13, 2003 at 14:47 UTC |