简体   繁体   English

C#从XML文件获取信息

[英]c# getting informaion from xml file

A want get all information which are in located in <forecast_conditions></forecast_conditions> tag for first ta I use 我首先要获取位于<forecast_conditions></forecast_conditions>标记中的所有信息

var for_cod = from currentCond in xdoc.Root.Descendants("current_conditions")
                         select currentCond;

I don;t know how to get information from 2,3 <forecast_conditions></forecast_conditions> tags because it have same names, maybe you have any ideas? 我不知道如何从2,3 <forecast_conditions></forecast_conditions>标记中获取信息,因为它具有相同的名称,也许您有什么想法?

xml file: http://www.google.com/ig/api?weather=vilnius&hleng=eng xml文件: http : //www.google.com/ig/api? weather=vilnius&hleng= eng

I am not sure what you exactly need. 我不确定您到底需要什么。 If you want to get all forecast_conditions for in a result set you can use this simple query 如果要获取结果集中的所有Forecast_condition,则可以使用此简单查询

 var query  = from t in doc.Descendants("forecast_conditions")
                         select t;

You may wanna see Weather Information from Google Weather using ASP.NET and LINQ to XML , also check out this article Using Google Weather API In AC# Application . 您可能想使用ASP.NET和LINQ to XML从Google Weather中查看天气信息 ,还可以查看本文在AC#应用程序中使用Google Weather API Its not using LINQ though. 它不使用LINQ。 Also check out this thread C# Pull XML data from google's weather API 还要检查此线程C#从Google的天气API中提取XML数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM