想要获取位于<forecast_conditions></forecast_conditions>
标签中的所有信息,我首先使用
var for_cod = from currentCond in xdoc.Root.Descendants("current_conditions")
select currentCond;
我不知道如何从2,3 <forecast_conditions></forecast_conditions>
标签获取信息,因为它有相同的名称,也许您有任何想法?
xml文件:http://www.google.com/ig/api?weather=vilnius&hleng=eng
答案 0 :(得分:1)
我不确定你到底需要什么。如果要在结果集中获取所有forecast_conditions,可以使用此简单查询
var query = from t in doc.Descendants("forecast_conditions")
select t;
您可能希望看到Weather Information from Google Weather using ASP.NET and LINQ to XML,也请查看此文章Using Google Weather API In A C# Application。它不使用LINQ。另请查看此帖子C# Pull XML data from google's weather API