Skip to Content
Perl and XML
book

Perl and XML

by Erik T. Ray, Jason McIntosh
April 2002
Intermediate to advanced content levelIntermediate to advanced
218 pages
6h 12m
English
O'Reilly Media, Inc.
Content preview from Perl and XML

Chapter 3. XML Basics: Reading and Writing

This chapter covers the two most important tasks in working with XML: reading it into memory and writing it out again. XML is a structured, predictable, and standard data storage format, and as such carries a price. Unlike the line-by-line, make-it-up-as-you-go style that typifies text hacking in Perl, XML expects you to learn the rules of its game—the structures and protocols outlined in Chapter 2—before you can play with it. Fortunately, much of the hard work is already done, in the form of module-based parsers and other tools that trailblazing Perl and XML hackers already created (some of which we touched on in Chapter 1).

Knowing how to use parsers is very important. They typically drive the rest of the processing for you, or at least get the data into a state where you can work with it. Any good programmer knows that getting the data ready is half the battle. We’ll look deeply into the parsing process and detail the strategies used to drive processing.

Parsers come with a bewildering array of options that let you configure the output to your needs. Which character set should you use? Should you validate the document or merely check if it’s well formed? Do you need to expand entity references, or should you keep them as references? How can you set handlers for events or tell the parser to build a tree for you? We’ll explain these options fully so you can get the most out of parsing.

Finally, we’ll show you how to spit XML back out, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

XML and Perl

XML and Perl

Mark Riehl, Ilya Sterin
Pro Perl

Pro Perl

Peter Wainwright
Programming Web Services with Perl

Programming Web Services with Perl

Randy J. Ray, Pavel Kulchenko
Perl Template Toolkit

Perl Template Toolkit

Darren Chamberlain, Andy Wardley, David Cross

Publisher Resources

ISBN: 059600205XSupplemental ContentErrata Page