O'Reilly logo

Amazon Hacks by Paul Bausch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

View XML Responses in a Browser

Here’s a quick way of testing XML/HTTP responses to make sure you’re getting the data you need.

One great thing about the XML/HTTP method of retrieving data from Amazon is that it’s easy to read the responses and know what you’re getting. Instead of relying on tools to parse the response, you can usually see exactly what data you’re working with by looking it at yourself.

This is where a browser that can display XML comes in handy. Because the requests are made with a URL over HTTP, requesting XML data is just like requesting a web page. If you’re ever puzzled by the results you’re getting from an XML/HTTP script, this is a great way to debug. Just copy the URL from your code (this may require writing the URL out to the page if you’re dynamically generating the URL) and paste it into your browser’s address field.

Tip

Some browsers are better than others at displaying XML in a human-readable form. Internet Explorer builds a nice tree outline and allows you to hide or show particular branches. Other browsers display the XML in plain text exactly as it appears in the response. Still others show a blank page, leaving you to “view the source” to see the XML.

Let’s take a simple product detail query:

http://xml.amazon.com/onca/xml3?t=insert associate tag 
            [RETURN]
            &dev-t=insert developer token&type=lite&f=xml&AsinSearch=0596005423

Paste this into the Address field of Internet Explorer, and you should see something like Figure 6-1.

Figure 6-1. Amazon “lite” XML ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required