in reply to Accessing attributes in XML::Simple
foreach $e (@{$data->{footnotes}}) { print "$e->{footnote}{content}\n"; }
You'd need to specify KeyAttr => [].
With the default KeyAttr => [qw( name key id )], the above should be
ormy $footnotes = $data->{footnotes}{footnote}; foreach my $id (keys %$footnotes) { print "$footnotes->{$id}{content}\n"; }
my $footnotes = $data->{footnotes}{footnote}; foreach my $footnote (values %$footnotes) { print "$footnote->{content}\n"; }
Don't forget ForceArray => [qw( car footnote )]. XML::Simple is the hardest XML parser to use :(
By the way, if you used GroupTags => { footnotes => 'footnote' }, you could write ->{footnotes}{footnote} as just ->{footnotes}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Accessing attributes in XML::Simple
by Jenda (Abbot) on Jan 02, 2010 at 12:48 UTC | |
by ikegami (Patriarch) on Jan 02, 2010 at 16:42 UTC | |
|
Re^2: Accessing attributes in XML::Simple
by sherab (Scribe) on Jan 05, 2010 at 03:28 UTC | |
by ikegami (Patriarch) on Jan 05, 2010 at 03:34 UTC | |
by sherab (Scribe) on Jan 05, 2010 at 03:36 UTC |