avi_2009 has asked for the wisdom of the Perl Monks concerning the following question:
This is the xml file. The code which is reading it is given below.<?xml version='1.0'?> <queries> <query> <name>topHosts</name> <layer>LINK</layer> <topN>20</topN> <datatype>topHosts</datatype> <filter></filter> </query> <query> <name>topHosts</name> <layer>LINK</layer> <topN>120</topN> <datatype>topHosts</datatype> <filter></filter> </query> </queries>
Result:$simple1 = XML::Simple->new(ForceArray=>1, KeepRoot=>1); $data1 = $simple->XMLin("query.xml"); print Dumper($data1) . "\n";
Now, I want to read the key elements (topN, layer, filter, name, datatype) values in different variables. But I did not find a any code which will read the above data structure and extract those values, looping through throught the number of queries. For example - code in this case should loop 2 times as you can see that there are two queries in the xml file (query.xml). Please help!$VAR1 = { 'queries' => [ { 'query' => [ { 'topN' => [ '20' ], 'layer' => [ 'LINK' ], 'filter' => [ {} ], 'name' => [ 'topHosts' ], 'datatype' => [ 'topHosts' ] }, { 'topN' => [ '120' ], 'layer' => [ 'LINK' ], 'filter' => [ {} ], 'name' => [ 'topHosts' ], 'datatype' => [ 'topHosts' ] } ] } ] };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML parsing problem
by ambrus (Abbot) on Mar 10, 2009 at 20:13 UTC | |
by runrig (Abbot) on Mar 10, 2009 at 20:25 UTC | |
by Your Mother (Archbishop) on Mar 10, 2009 at 20:57 UTC | |
|
Re: XML parsing problem
by ikegami (Patriarch) on Mar 10, 2009 at 19:55 UTC | |
|
Re: XML parsing problem
by CountZero (Bishop) on Mar 10, 2009 at 19:52 UTC | |
by grantm (Parson) on Mar 12, 2009 at 23:52 UTC | |
|
Re: XML parsing problem
by Herkum (Parson) on Mar 10, 2009 at 19:44 UTC |