rhxk has asked for the wisdom of the Perl Monks concerning the following question:
I want to load these to a hash array so I can sort by the date id and extract the data inside that date id. my perl is as such:<site-catalog> <site> <name>abc</name> <header> <date id = "1992-06-17T00:00:00"> <fullname>AybBemGim</fullname> <a>101 </b> <b>UNKN</b> ... <operator>Zarzand</operator> <agency>NONE</agency> <run-by>Pepo</run-by> <observables>UNKN</observables> </date> <date id = "1992-06-26T00:00:00"> <fullname>AybBemGim</fullname> <b>101</b> <l>+342809.83</l> .... </date> </header> </site> </site-catalog>
How can I read the date id and the elements inside this tree?#!/usr/bin/perl use XML::Simple; use Data::Dumper; $xmlfile = "/home/rob/xml/config.xml"; #create object $xml = new XML::Simple; #read XML file $hash = $xml->XMLin($xmlfile); %element = $hash->{site}->{header}->{date}; foreach $key (sort keys %element) { print $key; } #print Dumper $hash;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::Parser help
by rhxk (Beadle) on Feb 02, 2006 at 22:06 UTC |