まず、私の英語はすみません、私の母国語ではありません。だから私は基本的に私たちの電子商取引会社のためのWebアプリケーションを開発しています。 Amazon APIを使用してデータを取得しています。これらはXMLファイルにあります。以前はXMLで実際に作業したことがないので、私は学びたいと思っていますが、インターネット上で見つかったものは基本的なXML文書用です。深い2-3レベルのような簡単なforeachを使用して簡単に読み取ることができます。私はこの種のドキュメントにforeachを使用しようとしましたが、コードでは迷ってしまいました。このデータを使ってクラスのインスタンスを作成したいと思います。この例では、この製品には1つの製品(製品タグ)と10の製品(LowestOfferListingsタグ)しかありません。本当に複雑なXMLを読む(最大10レベル)
すべての要素を読み込んでインスタンスを作成するためにコード内で使用するものは何ですか?
私はC#を使用してい
つの応答(GetLowestOfferListingsForASINResponse)は、最大20の結果(GetLowestOfferListingsForASINResponse)
製品(プロダクト)がまたはオファー(LowestOfferListings)を有しても有さなくてもよいが、それを持つことができます確かに(識別子)を持っています。
P.S. GetLowestOfferListingsForASINResponse
の終了タグは、下のコードブロックには表示されません。なぜ私は考えていない。しかし最後に終了タグがあります
ここにはamazon APIを使用した基本的な応答があります。
<GetLowestOfferListingsForASINResponse xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01">
<GetLowestOfferListingsForASINResult ASIN="ASIN_VALUE" status="Success">
<AllOfferListingsConsidered>False</AllOfferListingsConsidered>
<Product>
<Identifiers>
<MarketplaceASIN>
<MarketplaceId>MARKETPLACE_ID_VALUE</MarketplaceId>
<ASIN>ASIN_VALUE</ASIN>
</MarketplaceASIN>
</Identifiers>
<LowestOfferListings>
<LowestOfferListing>
<Qualifiers>
<ItemCondition>New</ItemCondition>
<ItemSubcondition>New</ItemSubcondition>
<FulfillmentChannel>Merchant</FulfillmentChannel>
<ShipsDomestically>Unknown</ShipsDomestically>
<ShippingTime>
<Max>3-7 days</Max>
</ShippingTime>
<SellerPositiveFeedbackRating>80-89%</SellerPositiveFeedbackRating>
</Qualifiers>
<NumberOfOfferListingsConsidered>2</NumberOfOfferListingsConsidered>
<SellerFeedbackCount>190758</SellerFeedbackCount>
<Price>
<LandedPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>30.74</Amount>
</LandedPrice>
<ListingPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>30.74</Amount>
</ListingPrice>
<Shipping>
<CurrencyCode>USD</CurrencyCode>
<Amount>0.00</Amount>
</Shipping>
</Price>
<MultipleOffersAtLowestPrice>False</MultipleOffersAtLowestPrice>
</LowestOfferListing>
<LowestOfferListing>
<Qualifiers>
<ItemCondition>New</ItemCondition>
<ItemSubcondition>New</ItemSubcondition>
<FulfillmentChannel>Amazon</FulfillmentChannel>
<ShipsDomestically>True</ShipsDomestically>
<ShippingTime>
<Max>0-2 days</Max>
</ShippingTime>
<SellerPositiveFeedbackRating>98-100%</SellerPositiveFeedbackRating>
</Qualifiers>
<NumberOfOfferListingsConsidered>1</NumberOfOfferListingsConsidered>
<SellerFeedbackCount>226962</SellerFeedbackCount>
<Price>
<LandedPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>31.50</Amount>
</LandedPrice>
<ListingPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>31.50</Amount>
</ListingPrice>
<Shipping>
<CurrencyCode>USD</CurrencyCode>
<Amount>0.00</Amount>
</Shipping>
</Price>
<MultipleOffersAtLowestPrice>False</MultipleOffersAtLowestPrice>
</LowestOfferListing>
<LowestOfferListing>
<Qualifiers>
<ItemCondition>New</ItemCondition>
<ItemSubcondition>New</ItemSubcondition>
<FulfillmentChannel>Merchant</FulfillmentChannel>
<ShipsDomestically>Unknown</ShipsDomestically>
<ShippingTime>
<Max>0-2 days</Max>
</ShippingTime>
<SellerPositiveFeedbackRating>90-94%</SellerPositiveFeedbackRating>
</Qualifiers>
<NumberOfOfferListingsConsidered>3</NumberOfOfferListingsConsidered>
<SellerFeedbackCount>827887</SellerFeedbackCount>
<Price>
<LandedPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>31.68</Amount>
</LandedPrice>
<ListingPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>31.68</Amount>
</ListingPrice>
<Shipping>
<CurrencyCode>USD</CurrencyCode>
<Amount>0.00</Amount>
</Shipping>
</Price>
<MultipleOffersAtLowestPrice>False</MultipleOffersAtLowestPrice>
</LowestOfferListing>
<LowestOfferListing>
<Qualifiers>
<ItemCondition>New</ItemCondition>
<ItemSubcondition>New</ItemSubcondition>
<FulfillmentChannel>Merchant</FulfillmentChannel>
<ShipsDomestically>False</ShipsDomestically>
<ShippingTime>
<Max>3-7 days</Max>
</ShippingTime>
<SellerPositiveFeedbackRating>95-97%</SellerPositiveFeedbackRating>
</Qualifiers>
<NumberOfOfferListingsConsidered>1</NumberOfOfferListingsConsidered>
<SellerFeedbackCount>9606</SellerFeedbackCount>
<Price>
<LandedPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>34.53</Amount>
</LandedPrice>
<ListingPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>30.54</Amount>
</ListingPrice>
<Shipping>
<CurrencyCode>USD</CurrencyCode>
<Amount>3.99</Amount>
</Shipping>
</Price>
<MultipleOffersAtLowestPrice>False</MultipleOffersAtLowestPrice>
</LowestOfferListing>
<LowestOfferListing>
<Qualifiers>
<ItemCondition>New</ItemCondition>
<ItemSubcondition>New</ItemSubcondition>
<FulfillmentChannel>Merchant</FulfillmentChannel>
<ShipsDomestically>Unknown</ShipsDomestically>
<ShippingTime>
<Max>0-2 days</Max>
</ShippingTime>
<SellerPositiveFeedbackRating>80-89%</SellerPositiveFeedbackRating>
</Qualifiers>
<NumberOfOfferListingsConsidered>2</NumberOfOfferListingsConsidered>
<SellerFeedbackCount>457149</SellerFeedbackCount>
<Price>
<LandedPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>40.04</Amount>
</LandedPrice>
<ListingPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>36.05</Amount>
</ListingPrice>
<Shipping>
<CurrencyCode>USD</CurrencyCode>
<Amount>3.99</Amount>
</Shipping>
</Price>
<MultipleOffersAtLowestPrice>False</MultipleOffersAtLowestPrice>
</LowestOfferListing>
<LowestOfferListing>
<Qualifiers>
<ItemCondition>New</ItemCondition>
<ItemSubcondition>New</ItemSubcondition>
<FulfillmentChannel>Merchant</FulfillmentChannel>
<ShipsDomestically>Unknown</ShipsDomestically>
<ShippingTime>
<Max>0-2 days</Max>
</ShippingTime>
<SellerPositiveFeedbackRating>95-97%</SellerPositiveFeedbackRating>
</Qualifiers>
<NumberOfOfferListingsConsidered>1</NumberOfOfferListingsConsidered>
<SellerFeedbackCount>473643</SellerFeedbackCount>
<Price>
<LandedPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>40.05</Amount>
</LandedPrice>
<ListingPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>40.05</Amount>
</ListingPrice>
<Shipping>
<CurrencyCode>USD</CurrencyCode>
<Amount>0.00</Amount>
</Shipping>
</Price>
<MultipleOffersAtLowestPrice>False</MultipleOffersAtLowestPrice>
</LowestOfferListing>
<LowestOfferListing>
<Qualifiers>
<ItemCondition>New</ItemCondition>
<ItemSubcondition>New</ItemSubcondition>
<FulfillmentChannel>Merchant</FulfillmentChannel>
<ShipsDomestically>True</ShipsDomestically>
<ShippingTime>
<Max>0-2 days</Max>
</ShippingTime>
<SellerPositiveFeedbackRating>90-94%</SellerPositiveFeedbackRating>
</Qualifiers>
<NumberOfOfferListingsConsidered>2</NumberOfOfferListingsConsidered>
<SellerFeedbackCount>127</SellerFeedbackCount>
<Price>
<LandedPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>41.99</Amount>
</LandedPrice>
<ListingPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>38.00</Amount>
</ListingPrice>
<Shipping>
<CurrencyCode>USD</CurrencyCode>
<Amount>3.99</Amount>
</Shipping>
</Price>
<MultipleOffersAtLowestPrice>False</MultipleOffersAtLowestPrice>
</LowestOfferListing>
<LowestOfferListing>
<Qualifiers>
<ItemCondition>New</ItemCondition>
<ItemSubcondition>New</ItemSubcondition>
<FulfillmentChannel>Merchant</FulfillmentChannel>
<ShipsDomestically>Unknown</ShipsDomestically>
<ShippingTime>
<Max>3-7 days</Max>
</ShippingTime>
<SellerPositiveFeedbackRating>95-97%</SellerPositiveFeedbackRating>
</Qualifiers>
<NumberOfOfferListingsConsidered>1</NumberOfOfferListingsConsidered>
<SellerFeedbackCount>1141</SellerFeedbackCount>
<Price>
<LandedPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>42.38</Amount>
</LandedPrice>
<ListingPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>38.39</Amount>
</ListingPrice>
<Shipping>
<CurrencyCode>USD</CurrencyCode>
<Amount>3.99</Amount>
</Shipping>
</Price>
<MultipleOffersAtLowestPrice>False</MultipleOffersAtLowestPrice>
</LowestOfferListing>
<LowestOfferListing>
<Qualifiers>
<ItemCondition>New</ItemCondition>
<ItemSubcondition>New</ItemSubcondition>
<FulfillmentChannel>Merchant</FulfillmentChannel>
<ShipsDomestically>True</ShipsDomestically>
<ShippingTime>
<Max>0-2 days</Max>
</ShippingTime>
<SellerPositiveFeedbackRating>95-97%</SellerPositiveFeedbackRating>
</Qualifiers>
<NumberOfOfferListingsConsidered>1</NumberOfOfferListingsConsidered>
<SellerFeedbackCount>359758</SellerFeedbackCount>
<Price>
<LandedPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>43.09</Amount>
</LandedPrice>
<ListingPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>43.09</Amount>
</ListingPrice>
<Shipping>
<CurrencyCode>USD</CurrencyCode>
<Amount>0.00</Amount>
</Shipping>
</Price>
<MultipleOffersAtLowestPrice>False</MultipleOffersAtLowestPrice>
</LowestOfferListing>
<LowestOfferListing>
<Qualifiers>
<ItemCondition>New</ItemCondition>
<ItemSubcondition>New</ItemSubcondition>
<FulfillmentChannel>Merchant</FulfillmentChannel>
<ShipsDomestically>Unknown</ShipsDomestically>
<ShippingTime>
<Max>0-2 days</Max>
</ShippingTime>
<SellerPositiveFeedbackRating>98-100%</SellerPositiveFeedbackRating>
</Qualifiers>
<NumberOfOfferListingsConsidered>1</NumberOfOfferListingsConsidered>
<SellerFeedbackCount>5876</SellerFeedbackCount>
<Price>
<LandedPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>46.18</Amount>
</LandedPrice>
<ListingPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>46.18</Amount>
</ListingPrice>
<Shipping>
<CurrencyCode>USD</CurrencyCode>
<Amount>0.00</Amount>
</Shipping>
</Price>
<MultipleOffersAtLowestPrice>Unknown</MultipleOffersAtLowestPrice>
</LowestOfferListing>
</LowestOfferListings>
</Product>
</GetLowestOfferListingsForASINResult>
そのコード簡略化されていますきれいに見えます。ご回答有難うございます。私はシリアライゼーション/デシリアライゼーションを調べます。 基本的には、amazonで指定されたスキームを使用してクラスを作成し、xmlデータをこれらのクラスにシリアル化する必要があります。 – Gorkem
はい、msdnツールを使用します。コード内のクラスとしてスキーマにない3つのタグ(最初は応答3)を追加する必要があります。 – jdweng
私はいくつかの結果を何時間も得ようとしています。 XMLは本当に複雑です。私はamazonによって与えられたxsdを使ってクラスを作成しました。逆シリアル化しようとしていますが、コンソールウィンドウに{ '"は期待されていませんでした "というメッセージが表示され続ける"} いくつかの解決方法があります。これはちょっとイライラしています –
Gorkem