微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

解析xml文档时函数评估超时

如何解决解析xml文档时函数评估超时

我正在Xamarin项目中解析xml_doc。

当我在Visual Studio中的电话仿真器中运行代码时,一切都很好。

但是当我在手机上的应用中运行代码时,会抛出“功能评估超时”

代码,引发错误

private async Task displayForecast(string xml)
        {
            XmlDocument xml_doc = new XmlDocument();


            xml_doc.LoadXml(xml);

            // Get the city,country,latitude,and longitude.
            XmlNode loc_node = xml_doc.SelectSingleNode("weatherdata/location");

           
            var Weathers = new List<WeatherModel>();
     
            foreach (XmlNode time_node in xml_doc.SelectNodes("//time"))
            {
                // Get the time in UTC.
                DateTime time = DateTime.Parse(time_node.Attributes["from"].Value,null,DateTimeStyles.AssumeUniversal);
                
                // Get the temperature.
                XmlNode temp_node = time_node.SelectSingleNode("temperature");
                string temp = temp_node.Attributes["value"].Value;

   
                   Weathers.Add(new WeatherModel() //Filling List by data from xml file
                   {
                       Time = time.Hour.ToString() + ":" + time.Minute.ToString(),Temperature = 
                        Convert.ToString(Converter.FahrenheitToCelsius(Convert.Todouble(temp))) + " ℃",DayOfYear = Convert.ToString(time.DayOfYear),DayOfWeek = time.DayOfWeek.ToString()
                   });      
            }

            var groups = Weathers.GroupBy(p => p.DayOfWeek).Select(g => new Grouping<string,//Grouping List
               WeatherModel>(g.Key,g));
         
            DailyWeatherGroups = new ObservableCollection<Grouping<string,WeatherModel>>(groups);
            
            OnPropertyChange();
            
        }[![Errors][1]][1]

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。