Bonjour, j'ai crée un code qui affiche le temps pour une région bien déterminé,en utilisant google weather, mais il ne m'affiche rien,j'ai même essayé d'extraire les données à partir d'un fichier xml ,mais ça n'a pas fonctionné non plus, voici mon code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Xml.Linq;
namespace Wth
{
public partial class MainPage : PhoneApplicationPage
{
// Constructeur
public MainPage()
{
InitializeComponent();
XDocument loadedData = XDocument.Load("gWeather.xml");
var x from c in loadedData.Root.Element("weather").Elements() where c.Name "forecast_conditions" select c;
foreach (XElement element in x)
{
WeatherElement welement = new WeatherElement();
welement.condition = element.Element("condition").Attribute("data").Value;
welement.day = element.Element("day_of_week").Attribute("data").Value;
welement.high = element.Element("high").Attribute("data").Value;
welement.low = element.Element("low").Attribute("data").Value;
}
WeatherBox.ItemsSource = x;
}
public class WeatherElement
{
string Condition;
string Day;
string Low;
string High;
public string condition
{
get { return Condition; }
set { Condition = value; }
}
public string day
{
get { return Day; }
set { Day = value; }
}
public string low
{
get { return Low; }
set { Low = value; }
}
public string high
{
get { return High; }
set { High = value; }
}
}
}
}