in reply to More with XML Parser
If you're using a handler, you can get the data in "name" in your StartTag handler. The attributes are arguments to the handler, like this:
If you're using the Tree style, I'm not sure exactly where you can find the value of name... try using Data::Dumper to print out the tree and see where it shows up.my $data = <<STOP; <outside> <inside name="Wibble">some data</inside> </outside> STOP my $parser = new XML::Parser(Handlers => { Start => \&start_tag }); $parser->parse($data); sub start_tag { my $expat = shift; my $element = shift; my %attrs = @_; print $attrs{name}; }
use Data::Dumper; my $tree = $parser->parse($data); print Dumper $tree;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: More with XML Parser
by chromatic (Archbishop) on Apr 19, 2000 at 20:37 UTC | |
|
RE: Re: More with XML Parser
by btrott (Parson) on Apr 19, 2000 at 20:53 UTC |