Review: No Nonsense XML Web Development With PHP by Thomas Myer

Posted on Tue 10 January 2006 in PHP

At the end of November, I received a copy of `No Nonsense XML Web Development With PHP <http://www.amazon.com/exec/obidos/ASIN/097524020X/coffeecode-20?creative=327641&camp=14573&link_code=as1>`__, written by Thomas Myer, from Sitepoint Press. With our move to the Great White North in December and the recent holidays, I hadn't had a chance to crack the spine of the book... until my laptop died this weekend. While waiting for a new motherboard (sigh), I had a fine opprtunity to sit down and spend some quality time with the book today.

In a nutshell...

This is an excellent little book if you know your way around PHP but need to start working with XML and need some hands-on examples to complement theory. This book will give you a choice of tools: client-side XML manipulation with browser-based XSLT and EcmaScript DOM, or server-side XML manipulation with PHP extensions for SAX, DOM, SimpleXML, and XML-RPC, along with some criteria for determining which approach to use for different aspects of your project. Myer is an excellent, enjoyable writer, and the short, clear examples solidify his lessons. For the past few years my bible for XML reference material has been Elliot Rusty Harold's `XML in a Nutshell <http://www.amazon.com/exec/obidos/ASIN/0596007647/coffeecode-20/103-2990794-9250255?%5Fencoding=UTF8&camp=1789&link%5Fcode=xm2>`__, but `No Nonsense XML Web Development With PHP <http://www.amazon.com/exec/obidos/ASIN/097524020X/coffeecode-20?creative=327641&camp=14573&link_code=as1>`__ complements any reference book with its task-oriented introduction to a broad array of XML Web development technologies.

Update 2006-01-10

As a promotional offer, if you buy No Nonsense XML Web Development With PHP though sitepoint.com you'll get a PHP quick reference poster along with your order. That's cool.

I also updated the title of the book to remove (Build Your Own)—that's the name of the series, not the subtitle. Amazon led me astray there... thanks to the nice Sitepoint person who pointed that out to me today.

First impressions

XML Web development with PHP is a very ambitious scope, and browsing the table of contents reveals that the book tackles (Dan takes a deep breath):

  • XML standards: XML, XHTML, XPath, XSLT, DTDs, and DOM
  • Client-side XML manipulation: JavaScript DOM manipulation
  • PHP extensions: SAX, DOM, and SimpleXML
  • Syndication: RSS 0.91 and 1.0
  • Web services: XML-RPC
  • Databases and XML: storing XML in databases and converting relational data to XML

Whew! That's a huge list for a 360-page book, so you know right away that you're not going to get in-depth coverage of each of these topics. However, what you do get is an overview of the core concepts behind each of these topics (the why) with the critical information required to make practical use of the subject technology (the how). Myer then solidifies each topic with a clearly explained example that contributes towards a basic content management system.

I found this "building block" structure worked very well in practice. Each example makes sense in the context of the overall content management system, and the clarity of the short examples makes the XML Web technology under discussion very approachable for the reader.

Intended audience

This book is aimed at an intermediate PHP developer who does not have much knowledge about or experience with XML technologies. It is not padded with basic introductory information about PHP. For example, Myer assumes that you understand what the @ symbol does when you use it to prefix a PHP function, and in describing how to enable PHP extensions that are not enabled in a default PHP install, Myer simply offers the configure option for UNIX users and the DLL name for Windows users.

In fact, despite its title, the bulk of the book is not really about PHP; it is about XML Web application development. But that's cool, because this helps the reader avoid "every problem is a nail, and PHP is my hammer" tunnel vision. Also unusual for a technology-focused book on application development, Myer spends a full chapter urging the reader to invest some time in analyzing the application's requirements before diving into code. I consider this a reflection of the author's own experience as a consultant, and a completely sane topic to spend precious space on.

Writing style

Thomas Myer writes in a very personable, approachable, informal, and occasionally irreverent tone that I truly enjoyed. (Really. This is a way-technical book, and I had fun reading it, including the occasional giggle. Honestly.) I'm totally jealous! The natural explanatory style seems effortless, but I know damn well how hard Myer must have worked to achieve that result. Check out how he takes the piss out of Resource Description Framework (RDF):

In a hand-wavy sort of way, RDF is a standard for describing anything and what it has to do with anything else. Vague enough for you?

I love it.

Book layout

This is the first "No Nonsense" Sitepoint book that I have read, and I quickly came to respect the basic, clean layout. Sample code is always labelled with the appropriate file name; reference URLs appear as footnotes, and the occasional tip is well integrated into the text with a modest icon drawing your eye. Based on this experience, I would definitely buy another Sitepoint book.

Depth of coverage

You can get a lot done with the content of this book. While 360 pages probably isn't enough to explore all of the ins and outs of just one of the subject technologies like XPath or XSLT, 20 pages is enough to cover the most common use cases and offer tips on avoiding common problems. For example: I wrote my first XSLT-based application in 1999, and have used it on and off ever since, so I had assumed that I wouldn't learn anything new. But Myer is a damn good writer, and that starts with his choice about what not to write about. In his XSLT discussion, he clarified some points that I had stumbled over in the past (and would be likely to stumble over again in the future).

Kudos to Myer for including basic coverage of output-escaping with htmlentities() and input-filtering with regular expressions. It's nice to see more emphasis on security in XML application development.

Inaccuracies and typos

Minimal; I found a couple of minor typos.

  • Page 173: a reference to DOMDocument->createElement() is written as "create_element"
  • Page 178: a grammatical error: "However, PHP can't compare apples to oranges—in this case, objects to a string"

That's just me being incredibly nitpicky. Overall, the book has been well edited.

The verdict

In summary: this is a fine book, and I would recommend it if you want a different perspective on XML Web development than you'll get from most other books. Buy this book from Amazon

PHP