更新时间:2023-01-08 17:13:19
类似的方法将起作用:
string xml = "YourXml";
XElement doc = XElement.Parse(xml);
var Result = from a in doc.Descendants("yweather:forecast")
where a.Attribute("day").Value == "Mon"
select a.Attribute("text").Value;
或lambda语法:
var Result = doc.Descendants("yweather:forecast")
.Where(x=> x.Attribute("day").Value == "Mon")
.Select(x=> x.Attribute("text").Value);
您还可以参考此 SO帖子