我創建一個Windows Phone 7的應用程序中,我消耗的eBay鏈接將XML中的ebay webservice響應轉換爲C#對象?
獲得在以下格式
<findItemsByKeywordsResponse>
<ack>Success</ack>
<version>1.12.0</version>
<timestamp>2013-03-10T15:50:40.717Z</timestamp>
<searchResult count="100">
<item></item>
<item></item>
<item>
<itemId>221170783013</itemId>
<title>Harry Potter and the Order of the Phoenix (DVD, 2007, Full Frame) - New Unopened</title>
<globalId>EBAY-ENCA</globalId>
<primaryCategory>
<categoryId>617</categoryId>
<categoryName>DVDs & Blu-ray Discs</categoryName>
</primaryCategory>
<galleryURL>http://thumbs2.ebaystatic.com/m/mm6I9OfrWGLKdYk-gLVSacg/140.jpg</galleryURL>
<viewItemURL>http://www.ebay.com/itm/Harry-Potter-and-Order-Phoenix-DVD-2007-Full-Frame-New-Unopened-/221170783013?pt=US_DVD_HD_DVD_Blu_ray</viewItemURL>
<productId type="ReferenceID">62940319</productId>
<paymentMethod>PayPal</paymentMethod>
<autoPay>false</autoPay>
<postalCode>P3P1S9</postalCode>
<location>Canada</location>
<country>CA</country>
<shippingInfo>
<shippingServiceCost currencyId="USD">4.99</shippingServiceCost>
<shippingType>Flat</shippingType>
<shipToLocations>Worldwide</shipToLocations>
<expeditedShipping>false</expeditedShipping>
<oneDayShippingAvailable>false</oneDayShippingAvailable>
<handlingTime>1</handlingTime>
</shippingInfo>
<sellingStatus></sellingStatus>
<listingInfo></listingInfo>
<returnsAccepted>true</returnsAccepted>
<condition></condition>
<isMultiVariationListing>false</isMultiVariationListing>
<topRatedListing>false</topRatedListing>
</item>
<item>
<itemId>130861888976</itemId>
<title>Harry Potter and the Order of the Phoenix Year 5 by J. K. Rowling (2003,...</title>
<globalId>EBAY-US</globalId>
<primaryCategory>
<categoryId>279</categoryId>
<categoryName>Children & Young Adults</categoryName>
</primaryCategory>
<galleryURL>http://thumbs1.ebaystatic.com/m/mkjj5zzPkMQ6FRLW5FlvXZQ/140.jpg</galleryURL>
<viewItemURL>http://www.ebay.com/itm/Harry-Potter-and-Order-Phoenix-Year-5-J-K-Rowling-2003-/130861888976?pt=US_Childrens_Books</viewItemURL>
<productId type="ReferenceID">2327833</productId>
<paymentMethod>PayPal</paymentMethod>
<autoPay>false</autoPay>
<postalCode>30535</postalCode>
<location>Demorest,GA,USA</location>
<country>US</country>
<shippingInfo>
<shippingServiceCost currencyId="USD">4.0</shippingServiceCost>
<shippingType>Flat</shippingType>
<shipToLocations>US</shipToLocations>
<expeditedShipping>false</expeditedShipping>
<oneDayShippingAvailable>false</oneDayShippingAvailable>
<handlingTime>3</handlingTime>
</shippingInfo>
<sellingStatus>
<currentPrice currencyId="USD">12.99</currentPrice>
<convertedCurrentPrice currencyId="USD">12.99</convertedCurrentPrice>
<bidCount>0</bidCount>
<sellingState>Active</sellingState>
<timeLeft>P0DT0H21M54S</timeLeft>
</sellingStatus>
<listingInfo>
<bestOfferEnabled>false</bestOfferEnabled>
<buyItNowAvailable>false</buyItNowAvailable>
<startTime>2013-03-03T16:12:34.000Z</startTime>
<endTime>2013-03-10T16:12:34.000Z</endTime>
<listingType>Auction</listingType>
<gift>false</gift>
</listingInfo>
<returnsAccepted>false</returnsAccepted>
<condition>
<conditionId>1000</conditionId>
<conditionDisplayName>Brand New</conditionDisplayName>
</condition>
<isMultiVariationListing>false</isMultiVariationListing>
<topRatedListing>false</topRatedListing>
</item>
</searchResult>
<paginationOutput>
<totalPages>27</totalPages>
<totalEntries>2602</totalEntries>
<pageNumber>1</pageNumber>
<entriesPerPage>100</entriesPerPage>
</paginationOutput>
<itemSearchURL>http://www.ebay.com/sch/i.html?_nkw=harry+potter+phoenix&_ddo=1&_ipg=100&_pgn=1</itemSearchURL>
</findItemsByKeywordsResponse>
了整個響應的項目列表,我需要的列表或僅包含Title,Description,EndTime,ListType,currentprice的Items的ObservableCollections。
什麼是最優化的方式來編碼這個。我無法想象最簡單的方法,就像直接反序列化對C#對象的XML響應一樣。
我還沒有嘗試過任何代碼我目前困惑如何實現這一目標?
http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx – 2013-03-10 16:23:46
我不知道,如果易趣的做法,但如果它讓你獲得在json中的響應,使用網站json2csharp.com。它爲你做所有的工作。 – 2013-03-10 16:27:36
這是否[eBay支持示例](https://ebay.custhelp.com/app/answers/detail/a_id/2045/~/c%23.net-code-sample-to-call-ebay-trading-api -using-.net-framework-4)有幫助嗎? – 2013-03-10 16:31:21