gr.d has asked for the wisdom of the Perl Monks concerning the following question:
Below is a XML file
<?xml version='1.0'?> <employee> <name>Pradeep</name> <age>23</age> <sex>M</sex> <department>Coder</department> </employee>
And the perl code is
use XML::Simple; use Data::Dumper; $xml=new XML::Simple; $data=$xml->XMLin("data.xml"); print Dumper($data);
Now how do you parse if the XML file is
<?xml version='1.0'?> <employee="risc_31> <name>John Doe</name> <age>43</age> <sex>M</sex> <department>Analyst</department> </employee> <employee="risc_32> <name>Pradeep</name> <age>23</age> <sex>M</sex> <department>HR</department> </employee>
how can this be done using a foreach loop in perl NOTE: XML::Simple is easier for me Any help is appreciated!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Basic parsing XML perl - using FOREACH
by 1nickt (Canon) on Dec 30, 2015 at 06:28 UTC | |
by gr.d (Novice) on Dec 30, 2015 at 07:09 UTC | |
by 1nickt (Canon) on Dec 30, 2015 at 07:30 UTC | |
by Anonymous Monk on Apr 08, 2016 at 03:16 UTC | |
|
Re: Basic parsing XML perl - using FOREACH
by Laurent_R (Canon) on Dec 30, 2015 at 07:28 UTC |