XML::Simple usage in perl
Usin XML module i am able to read the value using statement
print "$data->{cpu}->{usr}";
But how can i read no. of child and name of child for any tag.
for example i want to find out names of all child -calls, cpu and mem - for tag <mac>.
similarly i want to find names of all child -scallPs and sreadPs-for tag <calls>.
Are they stored in some array?
Contents of xml can be unknown to me.
--------------------XML file -------------------
<mac>
<calls>
<scallPs>83234</scallPs>
<sreadPs>7462</sreadPs>
</calls>
<cpu>
<usr>10</usr>
<idle>87</idle>
</cpu>
<mem>
<freemem>5820258</freemem>
<freeswap>194320556</freeswap>
</mem>
</mac>
--------------------XML file -------------------
i am able to print xml file content
using
$data = $xml->XMLin("data.xml");
print Dumper($data);
But let me re-phrase my question like this.
by using xml parser
what statement will print : calls, cpu ,mem?
what statement will print : usr, idle
i pressume, child of any <tag> shall be stored in some array . so i can print all array element and size of the array.
thanks in advance
Last edited by bharatbsharma; 05-08-2010 at 05:40 AM.
Reason: more explanation
|