in reply to How to access results of XML::Simple?
This looks familiar ... ;)
Have been introduced to Data::Dumper yet? Here is what it makes of the XML 'tree' that is built by XML::Simple:Yields:use Data::Dumper; my $data = do {local $/;<DATA>}; my $xml = XMLin($data); print Dumper $xml;
$VAR1 = {
'label' => 'gene_of_interest',
'id' => '3'
};
From this we see that label and id are the 'top level'
keys, there is no 'gene' key. However, had the XML been
a bit more proper ...
Then all is well. :)use strict; use warnings; use XML::Simple; my $data = do {local $/;<DATA>}; my $xml = XMLin($data); # ... and you use the correct syntax ;) print $xml->{gene}->{id}, "\n"; print $xml->{gene}->{label}, "\n"; __DATA__ <?xml version="1.0" ?> <genes> <gene id = "3" label = "gene_of_interest" /> </genes>
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: XML::Simple
by jdporter (Paladin) on Dec 18, 2002 at 01:08 UTC | |
by PodMaster (Abbot) on Dec 18, 2002 at 01:20 UTC | |
by matth (Monk) on Dec 18, 2002 at 23:23 UTC | |
by PodMaster (Abbot) on Dec 19, 2002 at 00:04 UTC |