Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: is XML too hard?

by perrin (Chancellor)
on Mar 17, 2003 at 19:17 UTC ( #243756=note: print w/ replies, xml ) Need Help??


in reply to is XML too hard?

It is so tempting to tell this guy "you made the bed, now f'ing sleep in it!" Why can't you use a simple line-oriented flat-file model on XML? Because they designed it to work differently, and he was in on the design!

However, he doesn't make much of a case for the problem with using SAX. What's the real difference between using callbacks and writing a while (<STDIN>) loop? Not that much, in my opinion.


Comment on Re: is XML too hard?
Download Code
Re: Re: is XML too hard?
by grantm (Parson) on Mar 17, 2003 at 21:55 UTC
    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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2014-09-19 04:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (129 votes), past polls