2011-07-09 43 views

回答

2

Windows 7手機支持大部分C#,因此您可以像使用其他C#代碼一樣使用所有相同的方法來解析XML。查找XmlDocument或XDocument。

0

here is a full tutorial reference給你。使用這段代碼

string xmlData = 
    @"<ServiceReply> 
     <StockQuote symbol='IBM' price='32.50' quotetime='01/01/2010 12:21:00'/> 
     <StockQuote symbol='MSFT' price='21.20' quotetime='01/01/2010 12:20:30' /> 
     </ServiceReply> 
    "; 

:C#代碼解析這個XML

var quotes = from quote in dataDoc.Descendants("StockQuote") 
    let stamp = DateTime.Parse(quote.Attribute("quotetime").Value) 
    orderby stamp ascending 
    select new StockQuote 
    { 
     Symbol = quote.Attribute("symbol").Value, 
     Price = decimal.Parse(quote.Attribute("price").Value) 
    }; 

讓我們知道,如果它的工作原理。希望有幫助

3
var id = Convert.ToInt32(XDocument.Parse(xml).Root.Element("id").Value);