Python & XML

Drake, Fred L. Jr.; Jones, Christopher A.
O'Reilly
ISBN 0-596-00128-2
342pp
Date finished: 2002-12-12

This book divides into two parts.

Part one, the first seven chapters of the book, is a good introduction to processing XML with Python. Chapter 1 is a brief introduction to Python and to the PyXML package, and chapter 2 is a rather good introduction to XML fundamentals, explaining DTDs and the structure of XML documents, and giving a brief but helpful overview of relevant W3C specifications. Chapter 3 is a very good explanation of SAX, with lots of example code showing how to write SAX handlers, and chapter 4 on the DOM is also good. Chapter 5 covers XPath reasonably well, and chapter 6 is a tutorial on XSLT that gives the flavour of it but isn't close to being complete. Chapter 7 discusses validating XML documents briefly and then moves on to an example involving converting flat files into an XML format.

Part two is a number of uninvolving and rather jumbled chapters on web applications of XML. The problem starts with the end of chapter 7, which concludes with a page and a half about ebXML that says nothing useful. Chapter 8 discusses modules such as urllib and httplib, but it's not particularly rigorous in its explanation of HTTP; the discussion of URL quoting also seemed confusing and unlikely to help a newbie. Chapter 9 on SOAP starts promisingly with a reasonably good overview and then falls into very dry dissections of SOAP's encoding rules. The incomplete state of SOAP libraries for Python means that the examples all have to use Microsoft's SOAP implementation, requiring the Win32 extensions for Python.

Chapter 10 is a 60-page extended example, building a simple database that stores and retrieves chunks of XML and then tying it to a CGI script. Experienced Python users won't buy it, I think, because everything the example does could be implemented much more simply if the use of XML wasn't complicating the problem; shelve could be used to store and retrieve user profiles with greater speed and less complexity, for example. Examples that don't motivate are a running problem in the book; the SAX chapter example stores filesystem data (filename, file size, &c) as XML and then parses it, and someone who hasn't already drunk the XML potion will wonder why the additional complication is worth it. (The last three chapters also have noticeably more typos and grammar errors; perhaps deadlines were biting hard and these chapters had less editorial help.)

In short, the first seven chapters of the book are definitely worth reading if you want to do XML work with PyXML; the last three chapters can be safely skimmed or skipped altogether.

Tagged: python, xml

Permalink: http://books.amk.ca/2002/12/Python_and_XML.html

%T  Python & XML
%A  Jones, Christopher A.
%A  Drake, Fred L. Jr.
%I  O'Reilly
%P  342pp
%G  ISBN 0-596-00128-2
%@  2002-12-12
%K  python, xml

http://books.amk.ca

Contact me