我希望找到100.0
<ConvertedCurrentPrice currencyID="USD">100.0</ConvertedCurrentPrice>
的值
尝试
var price = from v in doc.Elements("Item").Elements("ConvertedCurrentPrice").Single()
但没有工作
XML:
<GetSingleItemResponse xmlns="urn:ebay:apis:eBLBaseComponents">
<Timestamp>2015-07-26T19:39:05.104Z</Timestamp>
<Ack>Warning</Ack>
<Errors>
<ShortMessage>Version specified is above current version.</ShortMessage>
<LongMessage>Version specified is above current version. Setting version to current release version.</LongMessage>
<ErrorCode>1.30</ErrorCode>
<SeverityCode>Warning</SeverityCode>
<ErrorClassification>RequestError</ErrorClassification>
</Errors>
<Build>E897_CORE_APILW_17290128_R1</Build>
<Version>897</Version>
<Item>
<ItemID>221373860717</ItemID>
<EndTime>2015-08-04T19:26:15.000Z</EndTime>
<ViewItemURLForNaturalSearch>http://www.ebay.com/itm/Hello-Kitty-Wind-Up-60-Minute-Kitchen-Timer-3-5-/221371860717</ViewItemURLForNaturalSearch>
<ListingType>FixedPriceItem</ListingType>
<Location>Trenton, New Jersey</Location>
<GalleryURL>http://thumbs2.ebaystatic.com/pict/2213718607178080_1.jpg</GalleryURL>
<PictureURL>http://i.ebayimg.com/00/s/ODg5WDYxMA==/z/6u0AAOxydlFS-Sez/$_1.JPG?set_id=880000500F</PictureURL>
<PrimaryCategoryID>98852</PrimaryCategoryID>
<PrimaryCategoryName>Home & Garden:Kitchen, Dining & Bar:Kitchen Tools & Gadgets:Timers</PrimaryCategoryName>
<BidCount>0</BidCount>
<ConvertedCurrentPrice currencyID="USD">100.0</ConvertedCurrentPrice>
<ListingStatus>Active</ListingStatus>
<TimeLeft>P8DT23H47M10S</TimeLeft>
<Title>Hello Kitty Wind Up 60 Minute Kitchen Timer-3.5"</Title>
<Country>US</Country>
<AutoPay>true</AutoPay>
<ConditionID>1000</ConditionID>
<ConditionDisplayName>New</ConditionDisplayName>
</Item>
</GetSingleItemResponse>
答案 0 :(得分:1)
您需要修复一些错误
XNamespace ns = "urn:ebay:apis:eBLBaseComponents";
var price = doc.Root.Elements(ns + "Item")
.Elements(ns + "ConvertedCurrentPrice")
.Single()
.Value;