Hello,
I'm trying to return the last 7 days of data from an xml web service but with no luck. Could someone please explain me to how I would accomplish this? The XML is as follows:
<node>
<api>
<usagelist>
<usage day="2011-01-01">
<traffic name="total" unit="bytes">23579797</traffic>
</usage>
<usage day="2011-01-02">
<traffic name="total" unit="bytes">23579797</traffic>
</usage>
<usage day="2011-01-03">
<traffic name="total" unit="bytes">23579797</traffic>
</usage>
<usage day="2011-01-04">
<traffic name="total" unit="bytes">23579797</traffic>
</usage>
</usagelist>
</api>
</node>
EDIT
The data I want to retrieve will be used to populate a line graph. Specificly I require the day attribute value and the traffic element value for the past 7 days. At the moment, I have the code below in place, howevewr it's only showing the first day 7 times and traffic for the first day 7 times.
XDocument xDocument = XDocument.Parse(e.Result);
var values = from query in xDocument.Descendants("usagelist")
select new History
{
day = query.Element("usage").Attribute("day").Value,
traffic = query.Element("usage").Element("traffic").Value
};
foreach (History history in values)
{
ObservableCollection<LineGraphItem> Data = new ObservableCollection<LineGraphItem>()
{
new LineGraphItem() { yyyymmdd = history.day, value = double.Parse(history.traffic) },
new LineGraphItem() { yyyymmdd = history.day, value = double.Parse(history.traffic) },
new LineGraphItem() { yyyymmdd = history.day, value = double.Parse(history.traffic) },
new LineGraphItem() { yyyymmdd = history.day, value = double.Parse(history.traffic) },
new LineGraphItem() { yyyymmdd = history.day, value = double.Parse(history.traffic) },
new LineGraphItem() { yyyymmdd = history.day, value = double.Parse(history.traffic) },
new LineGraphItem() { yyyymmdd = history.day, value = double.Parse(history.traffic) },
};
lineGraph1.DataSource = Data;
}