in reply to understanding XML::Parser

When I use strict; I get the error Global symbol "@tree" requires explicit package name. This is a good clue.

When I change

my $node1 = ${$tree[0]}{name};
to
my $node1 = ${$tree->[0]}{name};
everything works.

$tree[0] is the zero'th element of @tree.

$tree->[0] is the zero'th element of tree that is referenced by $tree.

Replies are listed 'Best First'.
Re^2: understanding XML::Parser
by rsiedl (Friar) on Jul 17, 2006 at 07:13 UTC
    Thanks.

    Is there an easier way to get a value if I know only the name of the element?

    For example: if i want the value of count which resides in search_results?

      Based on my XML decision tree, you may want to use a technology that abstracts the XML tree such that it gives you XPath capabilities. I just load the entire XML file into memory, then ask the object to give me the elements that match my criteria.