标签:ret foreach code pre rom query from div adk
以前在项目中解析xml中写的一个Linq解析xml的例子,摘录如下:
string retValue = "<root upmobile=\"12348\"><item><mobile>13361233119</mobile><time>2016-05-06 12:30:20</time>" + "<content><CDATA>满意</CDATA></content></item><item><mobile>18612345678</mobile><time>2016-05-06 19:30:20</time>" + "<content><CDATA>满意</CDATA></content></item></root>"; XDocument doc = XDocument.Parse(retValue); var query = from d in doc.Descendants().Where(x => x.Name == "item") select new { mobile = d.Element("mobile").Value, time = d.Element("time").Value, content = d.Element("content").Element("CDATA").Value }; foreach (var item in query) { Console.WriteLine(item.mobile); Console.WriteLine(item.time); Console.WriteLine(item.content); } Console.ReadKey();
标签:ret foreach code pre rom query from div adk
原文地址:http://www.cnblogs.com/l919310075/p/7294194.html