in reply to Re: XML::Parser Style=>Subs and undefined subroutines
in thread XML::Parser Style=>Subs and undefined subroutines

sorry, but what's wrong in using it like this...

$xs = new XML::Parser; die ("Can't find file: $completePathFile $!") unless -f($completePat +hFile); $xs->setHandlers( Start => \&openElem, End => \&closElem, Char => \&heresTheData, Default => \&forgetit ); $xs->parsefile($completePathFile); ##now, parses and logic sub openElem{ } sub closElem{ } sub heresTheData{ } sub forgetit{ }
You have to activate a flipflop variable when you open the desired tag. And deactivate it when this tag closes.

In between, you are able to process the data that is received. Or waiting for other(s) flipflop(s) before processing the incoming data. You could leave it like this, and the file is going to parse perfectly ('though without any profit :).

For me, this module is a great masterpiece. But I only know this one, because it is the one more easyly found at any WWW site.

Replies are listed 'Best First'.
Re: Re: Re: XML::Parser Style=>Subs and undefined subroutines
by mirod (Canon) on Oct 02, 2003 at 11:47 UTC

    Nothing wrong here, there are just easier ways to code most XML processing than this.

    BTW you don't have to use a flipflop variable, you can just call current_element on the parser object to get the element in which you are (and context will give you the stack of open elements), man XML::Expat::Parser is an oft-overlooked resource that will give you the list of methods you can use on the parser object.

    But really, try using XML::LibXML or XML::Twig, have a look at the various comparisons at xmltwig.com (look at the bottom 3 articles), and you will see what a difference XPath can make.