日期:2014-05-18 浏览次数:20407 次
<args token="1"> <username>hyby_zhangzhen</username> <password>*********</password> <syncid>hyby_zhangzhen</syncid> </args>
XDocument xmlDoc = XDocument.Parse(@" <args token=""1""> <username>hyby_zhangzhen</username> <password>*********</password> <syncid>hyby_zhangzhen</syncid> </args>"); var q = from c in xmlDoc.Descendants("args") where c.Attribute("token").Value == "1" select new { username = c.Element("username"), password = c.Element("password"), syncid = c.Element("syncid") }; foreach (var item in q) { Response.Write("<li>" + item.username.Name + ": " + item.username.Value); Response.Write("<li>" + item.password.Name + ": " + item.password.Value); Response.Write("<li>" + item.syncid.Name + ": " + item.syncid.Value); }