Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

XML and Perl

by davorg (Chancellor)
on Jan 27, 2003 at 19:19 UTC ( [id://230313]=bookreview: print w/replies, xml ) Need Help??

Item Description: Good introduction to XML processing with Perl

Review Synopsis:

  • XML and Perl
  • Authors: Mark Riehl and Ilya Sterin
  • ISBN 0-7357-1289-1
  • Publisher: New Riders Publishing
  • Released: 2002-10-14

One of Perl's great strengths is in processing text files. That is, after all, why it became so popular for generating dynamic web pages - web pages are just text (albeit text that is supposed to follow particular rules). As XML is just another text format, it follows that Perl will be just as good at processing XML documents. It's therefore surprising that using Perl for XML processing hasn't recieved much attention until recently. That's not saying that there hasn't been work going on in that area - many of the Perl XML processing modules have long and honourable histories - it'd just that the world outside of the Perl community doesn't seem to have taken much notice of this work. This is all set to change with the publication of this book and O'Reilly's Perl and XML.

XML and Perl is written by two well-known members of the Perl XML community. Both are frequent contributors to the "perl-xml" mailing list, so there's certainly no doubt that they know what they are talking about. Which is always a good thing in a technical book.

The book is made up of five sections. The first section has a couple of chapters which introduce you to the concepts voered in the book. Chapter one introduces you separately to XML and Perl and then chapter two takes a first look at how you can use Perl to process XML. This chapter finishes with two example programs for parsing simple XML documents.

Section two goes into a lot more detail about parsing XML documents with Perl. Chapter three looks at event-driven parsing using XML::Parser and XML::Parser::PerlSAX to demonstrate to build example programs before going to talk in some detail about XML::SAX which is currently the state of the art in event-driven XML parsing in Perl. It also looks at XML::Xerces which is a Perl inteface to the Apache Software Foundation's Xerces parser. Chapter four covers tree based XML parsing and presents examples using XML::Simple, XML::Twig, XML::DOM and XML::LibXML. In both of these chapters the pros and cons of each of the modules are discussed in detail so that you can easily decide which solution to use in any given situation.

Section three covers generating XML documents. In chapter five we look at generating XML from text sources using simple print statements and also the modules XML::Writer and XML::Handler::YAWriter. Chapter six looks at taking data from a database and turning that into XML using modules like XML::Generator::DBI and XML::DBMS. Chapter seven looks at miscellaneous other input formats and contains examples using XML::SAXDriver::CSV and XML::SAXDriver::Excel.

Section four covers more advanced topics. Chapter eight is about XML transformations and filtering. This chapter covers using XSLT to transform XML documents. It covers the modules XML::LibXSLT, XML::Sabletron and XML::XPath.

Chapter nine goes into detail about Matt Sergeant's AxKit, the Apache XML Kit which allows you to create a website in XML and automatically deliver it to your visitors in the correct format.

Chapter rounds off the book with a look at using Perl to create web services. It looks at the two most common modules for creating web services in Perl - XML::RPC and SOAP::Lite.

Finally, section five contains the appendices which provide more background on the introductions to XML and Perl from chapter one.

There was one small point that I found a little annoying when reading the book. Each example was accompanied with a sample of the XML documents to be processed together with both a DTD and an XML Schema definition for the document. This seemed to me to be overkill. Did we really need both DTDs and XML Schemas for every example. I would have found it less distracting if one (or even both) of these had been moved to an appendix.

That small complaint aside, I found it a useful and interesting book. It will be very useful to Perl programmers (like myself) who will increasingly be expected to process (and provide) data in XML formats.

Update: Added book details.

Replies are listed 'Best First'.
Re: XML and Perl
by mirod (Canon) on Jan 27, 2003 at 20:49 UTC
      Michel,

      Respectfully we all know you have a bee in your bonnet about the DOM ;-). But regardless of the problems processing XML with the DOM brings up, I'm not entirely sure that covering those problems in the presented code would be the best way to do it -- I can't stand books that present massively long examples -- I'd much rather be given something simple I can build on. Perhaps a box-out would be better though. I haven't read this book yet, but I will be sure to suggest that to Ilya as a change for the second edition.

      As far as encodings go, I seem to recall reading that the book covers this by simply stating that all XML parsers return their data in UTF-8, regardless of the input encoding, but then I've only flicked through it on the bookshelves so I can't be sure. I get the feeling that because XML::Twig deals with the encodings issue by messing with the original_string (which is possibly scarier than the alternatives of just leaving things in UTF-8) that you think it's terribly important that this be covered in detail, when I think that in the majority of situations people need to come out of their encoding-specific shells and get used to the world of unicode. I'd treat someone coding in perl4 style the same way.

      Regarding discussing why you would want to use XSLT, I'd rather keep this out of a technical book. This is a wishy washy issue, and I'd rather just get into the code, thanks. I guess mileage varies on this - personally I prefer nutshell-style books that just get down and dirty without any discussion of the whys.

      Overall I think your response is rather damning of what is a much better book than "Perl and XML" from O'Reilly, and given the choice of the two I'd pick this book any day.

      All, respectfully, IMHO ;-)

        Overall I think your response is rather damning of what is a much better book than "Perl and XML" from O'Reilly, and given the choice of the two I'd pick this book any day.

        I agree. I wasn't impressed with O'Reilly's Perl and XML either. I thought it's examples were far too simple and it spent too much time on trivial issues while only providing far too brief discussion of the important points.

        XML and Perl is definately an improvement, despite what opinions people many have on the DOM :)

Re: XML and Perl
by Anonymous Monk on Jan 28, 2003 at 11:45 UTC

    Nice review :)

    Second time reading through this I realized some extra clarification as to what book you're reviewing would be helpful. The title is rather generic, so just in case another comes along:

    • XML and Perl
    • Authors: Mark Riehl and Ilya Sterin
    • ISBN 0-7357-1289-1
    • Publisher: New Riders Publishing
    • Released: 2002-10-14

    Hope I got the right one :)

      Excellent point. I made the assumption that the site automatically build that info from the ISBN number. It probably should :)

      I've taken the liberty of stealing the details from your post and putting them into mine. Hope you don't mind.

      --
      <http://www.dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg

        I've taken the liberty of stealing the details from your post and putting them into mine. Hope you don't mind.

        Not at all, glad I could help :)

Re: XML and Perl
by Ryszard (Priest) on Jan 28, 2003 at 19:16 UTC
    We got this book at work, and having never worked with XML before I found the book not really that helpful. I found after reading a couple of chapters, skimming, looking at the examples my understanding of XML and how to do XML processing in perl was only a little better than what it was before the book.

    In order to complete a basic level of understanding, i got out #!/usr/bin/perl and started writing away.

    I personally would want something that started very basic, and went up the scale to complex and complete real world examples of XML based applications.

    It would be my opinion this book would not make a good addition to a library...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: bookreview [id://230313]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-24 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found