开发者

How to parse the xml string in Windows phone 7?

开发者 https://www.devze.com 2023-03-19 04:53 出处:网络
Please how to read the following xml string. <Ne开发者_如何学JAVAwDataset> <Table> <Id>1</Id>

Please how to read the following xml string.

 <Ne开发者_如何学JAVAwDataset>
  <Table>
  <Id>1</Id>
  </Table>
 </NewDataset>

i need to get the id .please tell me .


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


Windows 7 phone supports most of C#, so you can use all the same methods for parsing XML as you would in any other C# code. Look up XmlDocument or XDocument.


here is a full tutorial reference for you. the C# code parses this XML:

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>
     "; 

using this piece of code:

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)
     };

Let us know if it works. hope that helps

0

精彩评论

暂无评论...
验证码 换一张
取 消