Following an example for Amazon Web Service API from here I got the DataSet populated with an XML ResponseStream like so:
DS.ReadXml(responseStream);
It is then passed via DataBind to a GridView like so:
GridView1.DataSource = DS.Tables["ItemAttributes"];
GridView1.DataBind();
GridView2.DataSource = DS.Tables["Item"];
GridView2.DataBind();
The problem is, that I get all columns from that XML, and in two tables, and I want to show only certain columns (DetailPageURL, Author, Title) from XML attributes in one table. I tried things in resembling posts, but none worked. I tried also to pass the stream to XDocument before putting it on a GridView, but I get a “Root element is missing” error. Also, tried to extract those columns with Linq, wich did not work. My knowledge is limited, though, so I could be doing something wrong with the code.
The snippet for XML response that goes in the DataSet is:
<ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01">
<OperationRequest>
<HTTPHeaders>
<Header Name="UserAgent" Value="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4"/>
</HTTPHeaders>
<RequestId>fafe85b6-3002-49ec-b716-e2057f9b94a0</RequestId>
<Arguments>
<Argument Name="Operation" Value="ItemSearch"/>
<Argument Name="Service" Value="AWSECommerceService"/>
<Argument Name="Signature" Value="..."/>
<Argument Name="AssociateTag" Value="..."/>
<Argument Name="Version" Value="2011-08-01"/>
<Argument Name="Keywords" Value="harry potter"/>
<Argument Name="AWSAccessKeyId" Value="..."/>
<Argument Name="Timestamp" Value="2012-10-14T15:16:02.000Z"/>
<Argument Name="SearchIndex" Value="Books"/>
</Arguments>
<RequestProcessingTime>0.0701880000000000</RequestProcessingTime>
</OperationRequest>
<Items>
<Request>...</Request>
<TotalResults>8394</TotalResults>
<TotalPages>840</TotalPages>
<MoreSearchResultsUrl>...</MoreSearchResultsUrl>
<Item>
<ASIN>059035342X</ASIN>
<DetailPageURL>...</DetailPageURL>
<ItemLinks>...</ItemLinks>
<ItemAttributes>
<Author>J.K. Rowling</Author>
<Creator Role="Illustrator">Mary GrandPré</Creator>
<Manufacturer>Scholastic Paperbacks</Manufacturer>
<ProductGroup>Book</ProductGroup>
<Title>Harry Potter and the Sorcerer's Stone (Book 1)</Title>
</ItemAttributes>
To answer my own question, I declared two new DataTables and in them put the desired columns, like so:
All I need now is find a way to put the two tables together in one, since this is showing errors: