And That's Not All
As I demonstrated, the unmatchable power of Perl in the data processing world makes it the ideal candidate for XML processing, which just happens to be text data itself. Perl is great, more than great. As Larry Wall sayings go, "It makes difficult things easy and
In the following chapters, I will show you how Perl and XML are basically intertwined. As this book focuses on actually providing example solutions to problems, you'll be able to quickly apply these skills in your real world Perl XML application.
In this chapter, I showed you why Perl and XML are two powerful, great technologies separately, as well as gave a few reasons why Perl and XML provide a powerful solution to today's information processing challenges. I believe there is nothing like experience and actual examples, so I'll use the rest of the book to convince you why Perl and XML, although not originally intended to work together, are made for each other.
Chapter 2. Now Let's Start Digging
Now that we have presented a high-level concept of XML and Perl, it's time to see some of the tasks that we can accomplish when we combine these two tools. As we mentioned earlier, we will show you how XML and Perl complement each other and make
This chapter covers the concepts and basics of the most popular XML technologies. Each of these technologies is utilized in Perl applications throughout the book, and we provide a working example that clearly illustrates the proper way to use the respective Perl module. Here are the topics that we'll discuss in this chapter:
What Is XML Processing?
What is XML processing? That is an often-asked question today given the popularity of XML. In the context of this book, I'll define XML processing as any task that involves XML data (for example, reading, writing, generating, and transforming).
Examples of XML Processing
XML processing can mean different things to different people, depending on what is important to them. What are some XML-related
XML documents must be generated before they can be
As you can see, you have a number of options when it comes to support for generating XML. I'll discuss all of these modules in greater detail and present examples a little later in the book.
Once we've generated an XML document (or received one from another source), there are Perl modules that will help you validate the XML document. An XML document is
Parsing is a concept that goes back a long time (in programmer's time, not historical time).
data, in simple terms, is to break the data down into the fundamental
XML can be transformed to a number of different formats. For example, an XML document can easily be converted to another XML document, HTML, CSV, or any of a number of different formats. This feature of XML is very important and allows a great deal of flexibility when presenting XML data. There are a number of Perl modules that support XML transformation and they'll be discussed in detail throughout the book.
Remember, there is a difference between data and information. The
A short XML primer is included in Appendix A, "What Is XML?" to help refresh your memory or give you an abbreviated introduction to XML.
Parsers come in many different forms. Some XML parsers don't require any programming, you just provide an input XML document, and the parser generates the output data. Other XML parsers provide Application Programming Interfaces (APIs) that allow the programmer to manipulate its functionality from within the application code. APIs are usually highly customizable and come with many different features. In Perl, a parser module provides an API to an XML parser engine. This API hides most of the details of the inner workings from the typical user, while providing a clean, easy-to-use, and
Parsing an XML document involves reading the XML data and navigating through it while separating the contents of the XML document into meaningful components. Remember, XML data can come from a file, input stream (for example, a socket), a string, or just about any other possible data source. The most popular methods of parsing XML follow either the push model or the pull model. Each of these parsing
Push Model of an XML Parser
The push model, as shown in Figure 2.1, is the
Figure 2.1. Applications built using a push-based XML Parser play a passive role and receive data that is