jihednond
Messages postés143Date d'inscriptionjeudi 27 mars 2008StatutMembreDernière intervention 3 septembre 2011
-
12 juil. 2011 à 13:30
BunoCS
Messages postés15475Date d'inscriptionlundi 11 juillet 2005StatutModérateurDernière intervention23 avril 2024
-
12 juil. 2011 à 14:35
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; }
}
}
}
}
BunoCS
Messages postés15475Date d'inscriptionlundi 11 juillet 2005StatutModérateurDernière intervention23 avril 2024103 12 juil. 2011 à 14:35
Hello,
As-tu mis des breakpoints pour voir si x est bien remplie? Sinon, décompose ta requête.
Attention, tu as déclaré une classe dans une autre. C'est bien ce que tu voulais faire?
NB: à l'avenir, fais gaffe à la catégorie dans laquelle tu postes --> déplacé du côté de C#
@+
Buno
----------------------------------------
L'urgent est fait, l'impossible est en cours. Pour les miracles, prévoir un délai...