Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: is XML too hard?

by grantm (Parson)
on Mar 17, 2003 at 21:55 UTC ( #243816=note: print w/ replies, xml ) Need Help??


in reply to Re: is XML too hard?
in thread is XML too hard?

What's the real difference between using callbacks and writing a while (<STDIN>) loop?

I suspect the question was rhetorical but I'll bite anyway :-) Put simply, it's the difference between push and pull. If you're used to reading a file line-by-line, you're used to thinking in 'pull' mode - you tell the parser "give me the next thing". Using SAX or the XML::Parser handler style requires you to think in 'push' mode - the parser tells you when it has something interesting. (In Soviet Russia the XMLs parser call you)

I think Matt and the team have done a great job with XML::SAX. Sub-classing XML::SAX::Base allows you to very easily write code which concentrates on the bits you're interested in. However, to use this stuff you have to think in a different way. Rather than saying "give me this and I'll deal with it", you have to say something more like "I'm interested in 'x', when you find an 'x', give it to this routine which knows how to deal with it".

People are saying good things about using HTML::TokeParser to achieve a pull-style interface to XML. I haven't tried it myself yet - my needs are simple :-)


Comment on Re: Re: is XML too hard?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://243816]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2014-07-10 00:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (198 votes), past polls