Advantages of Event-Driven Parsers


Event-driven parsers have several advantages over tree-based parsers.

An event-driven parser can handle huge amounts of XML data. Let's say that you need to parse XML data in a file that is hundreds of megabytes in size. The parser works through the file, reading each line, triggering events when they're needed. A DOM-based parser would need to read the entire file into memory at once, something that might be difficult on smaller PCs or workstations. So, for the same XML data, a DOM-based parser requires more memory. Depending on the size of the XML data, it can be impractical (or even impossible ) to use a DOM-based parser.

Another advantage of an event-driven parser is the complete XML file doesn't need to be available to start parsing. That's because the event-driven parsers don't know anything about the XML data; for example, whether it is stored in a file or in memory. The only concern an event-driven parser has is to look for the relevant patterns and trigger the corresponding callback function. This is important if you're working in a client-server environment. An event-driven parser can parse XML data as it is read off a socket rather than waiting for the entire XML file to be delivered to the parser.



XML and Perl
XML and Perl
ISBN: 0735712891
EAN: 2147483647
Year: 2002
Pages: 145

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net