0
繼從here亞馬遜Web服務API一個例子,我有一個XML ResponseStream填充像這樣的數據集:選擇從XML數據集的某些屬性爲GridView控件
DS.ReadXml(responseStream);
它,然後通過DataBind已傳遞到GridView像所以:
GridView1.DataSource = DS.Tables["ItemAttributes"];
GridView1.DataBind();
GridView2.DataSource = DS.Tables["Item"];
GridView2.DataBind();
的問題是,我得到的所有列從XML,並在兩個表,我想表明在一個表中的XML屬性只有某些列(DetailPageURL,作者,標題)。我嘗試了類似帖子的東西,但都沒有奏效。我試圖將它傳遞給XDocument之前將它放在一個GridView,但我得到一個「根元素丟失」的錯誤。另外,試圖用Linq提取這些列,但沒有工作。但是我的知識是有限的,所以我可能會在代碼上做錯了什麼。
認爲雲在數據集XML響應的片段是:
<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>