Thursday, March 26, 2009

Amazon Webservice C# asp.net Live sample to get product Details all attibutes

Amazon Webservice C# asp.net Live sample to get node Item
 
using
System;

using

System.Data;

using

System.Configuration;

using

System.Collections;

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 tstamz : System.Web.UI.Page

{

string SalesRankOut;

protected void Page_Load(object sender, EventArgs e)

{

getItemDetails();

}

void getItemDetails()

{

//ItemnoCnt = Itemno;

XmlDocument doc = new XmlDocument();

doc.Load(

"http://xml-us.amznxslt.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=16ND0GSSVYMWG9M8ECG2&Operation=ItemLookup&IdType=ASIN&AssociateTag=wwwvislicom-20&ResponseGroup=Large,Offers&ItemId=B0018OKX68");

XmlNodeList lstIsValid = doc.GetElementsByTagName("IsValid");

if (lstIsValid.Count > 0 && lstIsValid[0].InnerXml == "True")

{

XmlNodeList lstItems = doc.GetElementsByTagName("Item");

if (lstItems.Count > 0)

{

XmlNode nItem = lstItems[0];

foreach (XmlNode nChild in nItem.ChildNodes)

{

if (nChild.Name == "DetailPageURL") //string compare !

{

String strURL = nChild.InnerXml; //our data !

}

else if (nChild.Name == "LargeImage")

{

foreach (XmlNode nURLImg in nChild.ChildNodes)

{

if (nURLImg.Name == "URL")

{

string strImage = nChild.InnerXml; //our data !

Response.Write(nChild.FirstChild.InnerText);

Label1.Text =

"<img src=" + nChild.FirstChild.InnerText + "></img>";

// Response.Write("<br>");

//Response.Write(nChild.LastChild.InnerText);

}

}

}

else if (nChild.Name == "ItemAttributes")

{

foreach (XmlNode nIA in nChild.ChildNodes)

{

//Look through each "ItemAttributes" to find the one

//we want again

if (nIA.Name == "Title")

{

String strTitle = nIA.InnerXml; //our data !

Response.Write(

"<li>Title:--- " + strTitle + "</li> ");

}

if (nIA.Name == "Feature")

{

String strFeature = nIA.InnerXml; //our data !

Response.Write(

"<li> " + strFeature + "</li> ");

}

}

}

else if (nChild.Name == "OfferSummary")

{

foreach (XmlNode nOS in nChild.ChildNodes)

{

//looking again

if (nOS.Name == "LowestNewPrice")

{

foreach (XmlNode nLNP in nOS.ChildNodes)

{

if (nLNP.Name == "FormattedPrice")

{

Response.Write(

"strPrice");

String strPrice = nLNP.InnerXml; //our data !

break; //done looking here.

}

}

}

}

}

else if (nChild.Name == "EditorialReviews")

{

foreach (XmlNode nCR in nChild.ChildNodes)

{

foreach (XmlNode nRev in nCR.ChildNodes)

{

if (nRev.Name == "Content")

{

Response.Write(

"<br> Description:");

Response.Write(nRev.InnerXml);

//Our review text!

string strReview = nRev.InnerXml;

}

}

}

}

}

}

}

}

}

No comments: