Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
My code to parse:<host name=jimmy> <function>web</function> <function>dns</function> <location>miami</function> </host>
My problem is this: when machines have multiple duties, they do not get printed when I attempt to parse the xml file. I am sure there is a simple solution. Thanks for your help.#!/usr/bin/perl # use module use XML::Simple; use Data::Dumper; # create object $xml = new XML::Simple (KeyAttr=>[]); # read XML file $data = $xml->XMLin("hosts.xml"); foreach $e (@{$data->{host}}) { print $e->{name}, "\n"; print $e->{function}, "\n"; }
Updated Steve_p - added code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML parsing
by crashtest (Curate) on May 09, 2005 at 22:41 UTC | |
by Anonymous Monk on May 09, 2005 at 23:29 UTC | |
by crashtest (Curate) on May 10, 2005 at 03:17 UTC | |
|
Re: XML parsing
by jhourcle (Prior) on May 09, 2005 at 22:04 UTC | |
by Anonymous Monk on May 09, 2005 at 22:36 UTC | |
by jhourcle (Prior) on May 09, 2005 at 22:56 UTC | |
|
Re: XML parsing
by devnul (Monk) on May 09, 2005 at 22:54 UTC |