Note that there are some explanatory texts on larger screens.

plurals
  1. POWP7 Return the last 7 days of data from an xml web service
    primarykey
    data
    text
    <p>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:</p> <pre><code>&lt;node&gt; &lt;api&gt; &lt;usagelist&gt; &lt;usage day="2011-01-01"&gt; &lt;traffic name="total" unit="bytes"&gt;23579797&lt;/traffic&gt; &lt;/usage&gt; &lt;usage day="2011-01-02"&gt; &lt;traffic name="total" unit="bytes"&gt;23579797&lt;/traffic&gt; &lt;/usage&gt; &lt;usage day="2011-01-03"&gt; &lt;traffic name="total" unit="bytes"&gt;23579797&lt;/traffic&gt; &lt;/usage&gt; &lt;usage day="2011-01-04"&gt; &lt;traffic name="total" unit="bytes"&gt;23579797&lt;/traffic&gt; &lt;/usage&gt; &lt;/usagelist&gt; &lt;/api&gt; &lt;/node&gt; </code></pre> <p><strong>EDIT</strong></p> <p>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.</p> <pre><code>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&lt;LineGraphItem&gt; Data = new ObservableCollection&lt;LineGraphItem&gt;() { 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; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload