XML technologies / XML / Perl & XML / Perl and XML / XML processors

(Excerpt from "Perl & XML" by Erik T. Ray & Jason McIntosh)

Having first explored the easy side of XML, we will now introduce some less pleasant features. These are things to bear in mind when working with XML and Perl.

When this book refers to an XML processor (or simply a processor, without meaning the PC’s CPU, which often has the same name), we mean any software that can read or write XML documents, or possibly both. We use the term in its broadest sense: what the program actually does with the data it finds in an XML document or writes into it does not concern us. The processor itself must know what it is doing, where its documents come from, or what should happen to a generated document.

Of course, an XML processor is not particularly interesting when it simply works on its own. In a program that does something really exciting or useful with XML, the processor is therefore just a subordinate component. It normally reads an XML file, using a “magical” parser to build data structures with which the main program can then do whatever it wants.

In Perl, modules make this division of labor possible: an XML processor normally uses the use function to load an existing package that provides a suitable programming interface. In most cases, this interface is object-oriented. For this reason, most Perl programs that process XML begin with the statement use XML::Parser or something similar. This single line delegates all the laborious parsing work to another module that has already been written. Your own program only needs to supply the XML documents and process the data read.

  

  

 

 

 

back to top