topical media & game development
mashup-amazon-08-08-03-AmazonYahoo-Default.aspx.cs / cs
Author: Francis Shanahan
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack) { }
string strKeywords = Request.QueryString["Keywords"];
string strSearchIndex = Request.QueryString["SearchIndex"];
if ((strKeywords != "") & (strKeywords != null))
{
XmlDocument myAmazonDoc = webUtility.GetUri("http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=[YOUR ID HERE]&Operation=ItemSearch&ResponseGroup=Medium&AssociateTag=francshanacom&SearchIndex=" + strSearchIndex + "&Keywords="+ strKeywords );
XmlDocument myYahooDoc = webUtility.GetUri("http://api.shopping.yahoo.com/ShoppingService/V1/productSearch?appid=[YOUR ID HERE]&query=" + strKeywords + "&results=10&start=1" );
// Create the new results document
XmlDocument myResults = new XmlDocument();
// Add a root node to the results document
XmlNode myRoot = myResults.CreateElement("MashupRoot");
myResults.AppendChild(myRoot);
// Add the amazon results to the main doc
XmlNode amazonTmp = myResults.ImportNode(myAmazonDoc.DocumentElement, true);
myResults.DocumentElement.AppendChild(amazonTmp);
// Add the yahoo results to the main doc
XmlNode yahooTmp = myResults.ImportNode(myYahooDoc.DocumentElement, true);
myResults.DocumentElement.AppendChild(yahooTmp);
if (myResults != null)
{
// Uncomment this line if you need to debug the mashed xml
//Response.Write(myResults.InnerXml);
string strResults = webUtility.DoXSLTransformation(myResults, "AmazonYahoo.xsl");
this.myLiteral.Text = strResults;
}
}
}
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.