Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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 :-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://243816]
[ww]: ++ambrus "their browser died just when...."
[ambrus]: ww: or they accidentally closed the window, or something. the exact excuse doesn't matter.
[ambrus]: you hear that on web forums frequently.
LanX Fermat 's famous browser
[ww]: ambrus agree; got the t-shirt, et al

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (17)
As of 2017-03-23 18:18 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (292 votes). Check out past polls.