|
next
|
 Subject: using document and web service... Author: tyler horath Date: 22 Oct 2008 01:53 PM Originally Posted: 22 Oct 2008 01:51 PM
|
So heres what Im trying to do. I am trying to search amazon for an ASIN using a name field I am provided. I want to get the ASIN using the search request url. Once I get the ASIN, I want to use that ASIN to get the product review. Heres my xslt. ITs not working because it puts all the ASINS in one url instead of puttting each ASIN in each url.
My XML is as follows
<catalog>
<product>
<name>White Widgets</name>
</product>
<product>
<name>Blue Widgets</name>
</product>
</catalog>
XSLT:
<xsl:template match="catalog/product" name="reviews">
<xsl:param name="keyword"><xsl:value-of select="translate(translate(name,' ','+'),' '' ', '')"/>
</xsl:param>
<xsl:variable name="url2" select="concat(' http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=[MY KEY]&Operation=ItemSearch&Keywords=',$keyword,'&SearchIndex=Blended')"></xsl:variable>
<xsl:variable name="ASIN">
<xsl:value-of select="document($url2, .)/a:ItemSearchResponse/a:Items/a:Item/a:ASIN"/>
</xsl:variable>
<xsl:variable name="url" select="concat(' http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=[MY KEY]&Operation=ItemLookup&ItemId=',$ASIN,'&ResponseGroup=Request,EditorialReview,Reviews,SalesRank&Version=2008-08-19')">
</xsl:variable>
<xsl:for-each select="document($url)/b:ItemLookupResponse/b:Items/b:Item/b:CustomerReviews/b:Review/b:Content">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>
|
|
|