TulipTools Internet Business Owners and Online Sellers Community

Full Version: Advanced XML parsing techniques using Perl
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Quote:. This second article in the series introduces the Perl programmer to the two major schools of XML parsing: tree parsing and event-driven parsing...

ntroduction

For a surprisingly broad range of Perl applications, the XML tool of choice is XML::Simple, which was the subject of Part 1 of this series (see Resources). XML::Simple converts XML input files into an easily manipulated Perl data structure, and writes such data structures back out as XML. Keep in mind, however, that this approach doesn't work under certain circumstances.

XML::Simple is not the best way to go when you need to build a representation of the XML document in memory and then either search it or transform it in fairly complex or unpredictable ways, which is where tree parsing comes in. If the XML document won't fit in memory or is a stream of unknown length, you can't use XML::Simple. You must use an event-driven parser. Most people find event-driven parsers a bit strange at first, but once you are used to this style of parsing, SAX might become your tool of preference.

The rest of this article will look at these two advanced ways of using Perl to parse XML..

full article: http://www-128.ibm.com/developerworks//l...arsing-XML