Geekspeak: July 29, 2002

Accessing Amazon.com using XML.

In April, Amazon.com released a web services query interface for its catalog. I thought this was a great feature but was disappointed that it didnt use SOAP since so many languages support that standard.

Amazon used a REST (Representational State Transfer) interface, where queries are issued using custom URLs and data is returned as plain XML. This is still a lot better than screen-scraping HTML pages, so over the July 4 holiday, I fired up a copy of Suns new Sun ONE Studio 4 and developed a Java client API for the Amazon REST interface.

Since the codes main job is to parse Amazon.coms XML, I evaluated several Java XML libraries, looking for the least complicated option. Java has native support for DOM and SAX APIs, but I found them both too low-level—too much code was required for something that should be simple. I then looked at two other libraries, Dom4j (www.dom4j.org) and JDOM (www.jdom.org), as well as two data-binding frameworks, Castor (www.castor.org) and Suns JAXB.

Dom4j was my pick—its easy to use and has built-in support for XPath, and it kept my code simple and short.

While writing this, I discovered that Amazon.com just announced (as of July 16) Version 1.0 of its XML query interface, which now supports SOAP as well as the REST interface. It was a fun exercise, anyway.