Hiho,
I'm trying to deserialize the following XML feed from the weather
channel but I'm having an issue with the nested arrays. I got as far as
getting the 'day' into arrays but I can't get the 'part' nested array
working.
This is my first hack at XML feeds and such, so any pointers as to how
to best do this or references/tutorials would be good.
(I'm doing all this in .NET 2.0 btw)
Ok, here's a snip of the feed:
<weather>
<loc>...</loc>
<cc>...</cc>
<dayf>
<day d="1" t="Tuesday" dt="Jul 27">
<hi>65</hi>
<low>48</low>
<sunr>7:09 AM</sunr>
<suns>5:37 PM</suns>
<part p="d">
<icon>34</icon>
<t>Mostly Sunny</t>
<wind>
<s>10</s>
<gust>N/A</gust>
<d>6</d>
<t>N</t>
</wind>
<ppcp>10</ppcp>
<hmid>63</hmid>
</part>
<part p="n">
<icon>45</icon>
<t>Showers Late</t>
<wind>
<s>10</s>
<gust>N/A</gust>
<d>22</d>
<t>NNE</t>
</wind>
<ppcp>50</ppcp>
<hmid>86</hmid>
</part>
</day>
<day d="2" t="Wednesday" dt="Jul 28">
<hi>65</hi>
<low>48</low>
<sunr>7:08 AM</sunr>
<suns>5:38 PM</suns>
<part p="d">
<icon>30</icon>
<t>Partly Cloudy</t>
<wind>
<s>11</s>
<gust>N/A</gust>
<d>337</d>
<t>NNW</t>
</wind>
<ppcp>20</ppcp>
<hmid>71</hmid>
</part>
<part p="n">
<icon>29</icon>
<t>Partly Cloudy</t>
<wind>
<s>4</s>
<gust>N/A</gust>
<d>10</d>
<t>N</t>
</wind>
<ppcp>20</ppcp>
<hmid>87</hmid>
</part>
</day>
</dayf>
</weather>
And here's part of my class:
[XmlRoot("weathe r")]
public class Weather
{
public Loc loc;
public Cc cc;
[XmlArrayItem("d ay")]
public Day[] dayf;
}
*snip*
public class Day
{
[XmlAttribute]
public string t;
public string hi;
public string low;
}
Now, this is all I can get working. I know there should be a class
called Dayf as well but as soon as I try that, it stops working.
I wasn't able to find any examples as to how to do nested arrays in the
MS docs. Please bear with my noviceness in this issue :)
Cheers