Basic Search  Advanced Search   
Topics Resources Free Library Software XML News About Us
  You are here: home Info Bank Articles » The XML Web Saturday, 8 March 2008

Back to Articles Page      


The XML Web


Author: Darshan Singh,

Managing Editor,

April 14, 2002

Updated on April 22, 2002: Click here to see an example of integrating Microsoft Office XP Smart Tags with the Google Web API.




In this short article, I'll talk about how the "HTML Web" is moving towards the "XML Web". Associates XML Interface

Recently,, Inc. announced the XML interface for their Associates. This HTTP based XML interface allows associates to build targeted, customized Amazon placements on their Web site. For instance, an associate can send an HTTP request to search for various product lines (books, music, etc.) and pass the subject keywords as part of the URL query, and get back the results in XML (instead of HTML).


First, let's look at the URL syntax and then we'll look at an example:[Associates ID]&l=st1&search=[keywords]&mode=[product line]&p=102&o=1&f=xml


The above HTTP URL accepts associate ID, product line, search keywords, and few other required parameters. is an Amazon associate for quite some time now. Let's try the above URL using the PerfectXML associate ID. Let's search for books on MSXML:


Browse to the above URL and you'll see the results returned in the XML format. The associates can now very easily parse the returned XML and present the results either by applying a custom XSL Transformation or use XML processing APIs (such as DOM or SAX) to get to the returned data elements.


Amazon also offers the ability to search for best selling products in a particular browse category (VHS, DVD, Toys, Baby, etc.) and get the results back in XML format. Let's search for best selling baby toys on


The browse category of 540988 refers to the Baby products and mode=toys specify the product line.



Let's look at a very simple example to use the Associates XML Interface. We'll use MSXML ServerXMLHTTP class to send the HTTP GET request to one of the above URL (the baby toys on, get back the XML, and apply XSL Transformation to pretty print the results.


View Demo


Let's begin by looking at the ASP code that use MSXML 3.0 ServerXMLHTTP class, sends the HTTP GET request, gets the XML response back, loads the XSL Transformation file using MSXML DOM, applies the transformation and sends the result HTML to the client:




Option Explicit

Dim ObjSXH, ObjXML, ObjXSL

'Using MSXML 3.0 ServerXMLHTTP Class

Set ObjSXH = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")


'GET Request _

"GET", _

"", _



'Send the request

ObjSXH.send ""


'If the request succeeded

If ObjSXH.status = 200 Then


'returned XML as a DOMDocument

Set ObjXML = ObjSXH.responseXML

'Load the XSLT stylesheet

Set ObjXSL = Server.CreateObject("Msxml2.DOMDocument.3.0")

ObjXSL.load Server.MapPath("amazontoys.xsl")

'Apply XSL Transformation and write the HTML result

Response.Write (ObjXML.transformNode(ObjXSL))


Response.Write "An error occurred. Please try later."

End If



And here is the XSL Transformation file used in the above ASP page:







<xsl:output method="html" indent="yes"/>


<xsl:template match="/">

<table align="center" width="600" cellpadding="3" cellspacing="1" bgcolor="#333333">


<xsl:for-each select="//product">



<td bgcolor="#EEEEEE" width="300" valign="top">

<b><xsl:value-of select="title" /></b><br />

<font color="gray">

Author: <xsl:value-of select="author" /> <br />

Sales Rank: <b><xsl:value-of select="ranking" /></b>




<td bgcolor="#FFFFFF" width="300" valign="top" align="center">

<a href="{tagged_url}"><img border="0" src="{image}" /><br />Buy</a>









Click here to view the output of ASP+XSLT code.


-          Visit if you have any questions and discuss it on Amazon discussion forums.


-          Visit to download the package that helps in creation of complex, highly targeted ads from the raw Amazon XML interface.


-          The current limitations include:

         A single XML query can only generate results for one product line at a time, and

         The result set is currently restricted to the maximum of 15 items.


-          Send any questions or comments to


-          Amazon recommends caching the XML results.


Section Summary

During one of the weekend in August 2001, I wrote an ASP.NET Web service to get the Amazon and B&N sales rank and price information (SalesRankNPrice Web service) it was not fun trying out various regular expressions to find the "best" one that always select the correct values from the HTML that I got from the book store Web sites. I am glad that the HTML Web is now moving towards the XML, and it certainly is good news for us (the developers), we can use our imagination and build new intelligent applications around this XML Web. Drop a line at and let me know your thoughts on this!

Google Web APIs

On April 11, 2002, Google made a public release of the Google Web APIs Beta 2 SOAP based API that currently supports three major operations:


1.      Search the Web,

2.      Request a spell correction, and

3.      Retrieve the cached Web page.


The Web APIs home page ( allows downloading the developer's kit that contains:


-          A WSDL file that formally describes the service.

-          API Reference documentation (HTML format), and Readme.txt.

-          A custom Java library that provides a convenience wrapper for Java programmers.

-          Documentation for the above example Java library.

-          Example SOAP messages and responses.

-          Sample C# .NET code application that uses the above Web service.

-          The Readme.txt file also contains the SOAP::Lite 0.52 example.


In order to use Google Web APIs you first must register with Google to receive an authentication key. Go ahead and download the kit, register and obtain your license key (free); and begin using the Google Web service. It is required to pass the license number (authentication) key with each Web method call you make to the Google Web service.


Click here to view some example of applications that you can create using the Google Web API.


Using Microsoft SOAP Toolkit 2.0

Let's look at an ASP VBScript example to search for the word "certification" on the Web site using the Google Web API.


We assume that you have GoogleSearch.wsdl (from the download kit) saved under the same directory as the following ASP page:




Option Explicit

Dim ObjSOAPClient, ResultNodeList

Dim MyGoogleKey, SearchStr

Dim iIndex, ApproxResultCount


SearchStr = " certification"


Set ObjSOAPClient = Server.CreateObject("MSSOAP.SoapClient.1")

'Initialize the SOAPClient with the WSDL

ObjSOAPClient.mssoapinit Server.MapPath("GoogleSearch.wsdl")


'Call doGoogleSearch Web method

Set ResultNodeList = ObjSOAPClient.doGoogleSearch _

(MyGoogleKey, SearchStr, 0, 1, False, "", False, "", "", "")


For iIndex = 0 To ResultNodeList.length - 1

If ResultNodeList.Item(iIndex).nodeName = "estimatedTotalResultsCount" Then

ApproxResultCount = ResultNodeList.Item(iIndex).nodeTypedValue

Exit For

End If



Response.Write ApproxResultCount



The above code uses Microsoft SOAP Toolkit high-level API to call the Web service method doGoogleSearch, which returns the complex XML data structure. The resultant XML can be processed either using SOAP Message Object (SMO) or using MSXML. The above code uses MSXML IXMLDOMNodeList type variable to store the XML result returned by the doGoogleSearch Web method. The code then iterates over the IXMLDOMNodeList looking for the estimatedTotalResultsCount, and returns the node value to the client using Response.Write. The estimatedTotalResultsCount currently is just 7, as Google has not yet indexed the just announced IBM XML Certification Resource Center ( on PerfectXML.


-          Visit Google Web API FAQ ( to see a list of frequently asked questions.


-          Join the Google Web API discussions at


-          Initially, Google shipped the WSDL file as part of the download ZIP file; now it's also available on Google Web site at


-          If you are using SOAP::Lite to access the Google Web service, use the SOAP::Lite version 0.52 or higher.


-          Click here to view the JSP code that uses Google Web API.


-          Click here for some details on how to use the API with .NET.


-          Click here to view the gSOAP example that uses the Google Web API.


-          The current limit on the search API: maximum of 1000 queries per day, and each query returns maximum of 10 result entries. After the 1000 queries on a same day, the Web service returns the SOAP Fault response. Maximum number of words allowed per query is ten (maximum of 2048 bytes). And if you wish to search only the specific sites (using the site: attribute), maximum of one site URL can be provided.


-          Spelling request is also limited by ten words (2048 bytes) per query string.


-          As the Google Web API returns complex data types, it cannot be directly used via the Office XP Web service toolkit; the workaround would be to use MSXML. See the article Handling Complex SOAP Data Types in XML Web Services on MSDN for more information on this.


-          Send any questions or comments to


-          Try the Google Web API interface using the SOAP Test Client:

Browse to the SOAP Test Client and enter following values in the form:

Post URL:

Content-Type: text/xml; charset=utf-8

SOAPAction: urn:GoogleSearchAction

SOAP Request:

<?xml version='1.0' encoding='UTF-8'?>
    <ns1:doGoogleSearch xmlns:ns1="urn:GoogleSearch" 
      <key xsi:type="xsd:string">****ENTER YOUR KEY HERE****</key>
      <q xsi:type="xsd:string">PerfectXML</q>
      <start xsi:type="xsd:int">0</start>
      <maxResults xsi:type="xsd:int">10</maxResults>
      <filter xsi:type="xsd:boolean">true</filter>
      <restrict xsi:type="xsd:string"></restrict>
      <safeSearch xsi:type="xsd:boolean">false</safeSearch>
      <lr xsi:type="xsd:string"></lr>
      <ie xsi:type="xsd:string">latin1</ie>
      <oe xsi:type="xsd:string">latin1</oe>
Remember to update the above SOAP request and put your Google license (authentication) key within in the <key> tag.

Summary, the biggest online bookstore on the earth, recently announced the XML integration API to allow their associates to build targeted, customized Amazon placements., the world's best search engine, recently announced the SOAP-based Web API to search the Web, request a spell correction, or to request a cached Web page.


In this article, we took the above two examples to illustrate how the HTML Web is moving towards the "XML Web" and it's just a beginning. We'll see many such examples in the coming days.

Related Links


Back to Articles Page      

  Contact Us | E-mail Us | Site Guide | About PerfectXML | Advertise ©2004 All rights reserved. | Privacy