My XML file looks like this:
<eLinkResult>
<LinkSet>
<DbFrom>nuccore</DbFrom>
<IdList>
<Id>133909243</Id>
</IdList>
<LinkSetDb>
<DbTo>taxonomy</DbTo>
<LinkName>nuccore_taxonomy</LinkName>
<Link>
<Id>417290</Id>
</Link>
<Link>
<Id>417289</Id>
</Link>
<Link>
<Id>405948</Id>
</Link>
</LinkSetDb>
</LinkSet>
</eLinkResult>
I am looking to get all <Id> information, and I know how to extract if there was one <Id> like so:
my $test="Some URL;
my $Result = get ($test);
my $Data = $Parser->XMLin($Result);
my $x=0;
if (exists($Data->{LinkSet}{LinkSetDb}->[0]->{Link}{Id})) {
$TaxId=$Data->{LinkSet}{LinkSetDb}{Link}->[0]->{Id};
or just
if (exists($Data->{LinkSet}{LinkSetDb}{Link}{Id})) {
$TaxId=$Data->{LinkSet}{LinkSetDb}{Link}{Id};
}
However when i try to use the XML file above I get Not a HASH reference
I also tried
foreach (@{$Data->{LinkSet}{LinkSetDb}{Link}{Id}}) {
Print $_;
}
But Still I get an error, is there a way so I can get all the <Id> without specifying which one I want?