Question Can't Extract a value a Dataset Created from Amazon XML Feed

Jasmine250

New member
Joined
Jun 10, 2008
Messages
2
Programming Experience
Beginner
Hi Everyone

I've just joined and hope someone can help me out :) (I don't have a great deal of experience though.)

I'm using REST with Amazon to use their 'top Sellers' feed. The data comes down ok but since it only provides 'title' and 'asin' I need to carry out another request to get the full details of the top selliing products.

In order to do this I need to extract the 'asin' number from the first dataset I've created, and then concatenate it to a new string for the second request.

The concatenation isn't a problem - just getting the value, I can't get the value whatever I try!!

Many thanks

Here's my code: [The dataset is bound to a datagrid simply to display results]

sub page_load(Src as Object, E as EventArgs)

Dim RESTstring = "http://webservices.amazon.co.uk/onca/xml?Service=AWSECommerceService&Operation=ItemSearch&AWSAccessKeyId=116AQMJ35GESH5XBF1G2&AssociateTag=wii07-21&SearchIndex=Toys&Title=Power%20Rangers&Sort=salesrank&ResponseGroup=Large&Style=http://www.wiiuser.co.uk/transform.xslt"
Dim myDataset as New Dataset()
Dim myDataset2 as New Dataset()
myDataSet.ReadXML(RESTstring)

Dim arASIN() As String
ReDim arASIN(myDataset.Tables(0).Rows.Count)
For i As Integer = 0 To myDataset.Tables(0).Rows.Count - 1
arASIN(i) = myDataset.Tables(0).Rows(i).Item(0).ToString
Next

RESTstring ="http://webservices.amazon.co.uk/onca/xml?Service=AWSECommerceService&SubscriptionId=116AQMJ35GESH5XBF1G2&Operation=ItemLookup&ItemId=" & arASIN(0) & "&ResponseGroup=Small"
myDataSet2.ReadXML(RESTstring)
dgAmazon.Datasource = myDataSet2
dgAmazon.DataMember = "item"
dgAmazon.DataBind()

end sub
 
You have to add a WebReference and use the generated proxy class to interact with the web service. Here is some help Implementing Amazon Web Services in VB.NET, it might be outdated, but the general thought is using the webreference class. (you may have your reasons to try out REST, but only SOAP interface is included in .Net library)
 
Hi John

Thanks for you prompt reply.

My understanding (I may have this completely wrong - it has got me going round in circles at times.) is that for REST you don't use the proxy generation etc. You simply need to use GetXML(...) to get the data and use an xslt file where you need to flatten the XML out a little. The code I included works OK and does get results to display. I just am not good enough at the coding to get at one piece of data to use in a second REST request.

I initially tried to use SOAP as it seemed easier once you have the data reading cracked but my coding ability wasn't up to it. I've never used VS so I used Dreamweaver CS3 to generate a proxy (successfully) and managed to get all the nodes from the Web Service to display correctly in the components panel. DW generated a code-behind xx.vb file which I referenced on my web page. I even managed to get very limited data to display on a web page for a simple ItemLookup on one item. However, when I tried using a BrowseNodeLookup it all when a bit wrong. I found several examples which I tried to use but they came up with compiler errors. Whether it was something to do with the xx.vb file I don't know. If you want more details of my attempts with SOAP I'll gladly send post them.

I am open to use any method that I can get to work as I've spent so long trying to figure this out.

If you or any of your colleagues can help me I'd be very grateful.

Thanks!:)
 
Here is some ws consumer code that should be comparable:
VB.NET:
Dim serv As New AWSECommerceService.AWSECommerceService

Dim req As New AWSECommerceService.ItemSearchRequest
req.SearchIndex = "Toys"
req.Title = "Power Rangers"
req.Sort = "salesrank"
req.ResponseGroup = New String() {"Large"}

Dim search As New AWSECommerceService.ItemSearch
search.AWSAccessKeyId = akid
search.AssociateTag = atag
search.Request = New AWSECommerceService.ItemSearchRequest() {req}

Dim response As AWSECommerceService.ItemSearchResponse = serv.ItemSearch(search)
Dim item As AWSECommerceService.Item = response.Items(0).Item(0)
I don't know the AWS request model, so I don't know where to go from there, but I see the item has various fields and info.
 
Back
Top