OK this should be easy but I am missing a trick here. I have an XML feed (example file here http://www.stormtrack.co.uk/test.xml )
For each child element, <topwindspeed>, <topmintemperature> and <topmaxtemperature> I need to get the 10 locations and wind/temp values into a list for now
I can get the 30 locations but not by child element.
Can anyone point me in the right direction?? [NB. This is private hobby work]
This is what I have so far...
--------------------------------------------------------
XmlDocument xDoc = new XmlDocument();
xDoc.Load("http://www.stormtrack.co.uk/test.xml");
List<string> locList = new List<string>();
XmlNodeList locNodes = xDoc.GetElementsByTagName("location");
for (int i = 0; i < locNodes.Count; i++)
{
locList.Add(locNodes[i].InnerXml); //gives 30 values
}
List<string> windList = new List<string>();
XmlNodeList windNodes = xDoc.GetElementsByTagName("windspeed");
for (int i = 0; i < windNodes.Count; i++)
{
windList.Add(windNodes[i].InnerXml); //gives 10 values
}
List<string> tHiList = new List<string>();
XmlNodeList tHiNodes = xDoc.GetElementsByTagName("maxtemperature");
for (int i = 0; i < tHiNodes.Count; i++)
{
tHiList.Add(tHiNodes[i].InnerXml); //gives 10 values
}
List<string> tLoList = new List<string>();
XmlNodeList tLoNodes = xDoc.GetElementsByTagName("mintemperature");
for (int i = 0; i < tLoNodes.Count; i++)
{
tLoList.Add(tLoNodes[i].InnerXml); //gives 10 values
}
For each child element, <topwindspeed>, <topmintemperature> and <topmaxtemperature> I need to get the 10 locations and wind/temp values into a list for now
I can get the 30 locations but not by child element.
Can anyone point me in the right direction?? [NB. This is private hobby work]
This is what I have so far...
--------------------------------------------------------
XmlDocument xDoc = new XmlDocument();
xDoc.Load("http://www.stormtrack.co.uk/test.xml");
List<string> locList = new List<string>();
XmlNodeList locNodes = xDoc.GetElementsByTagName("location");
for (int i = 0; i < locNodes.Count; i++)
{
locList.Add(locNodes[i].InnerXml); //gives 30 values
}
List<string> windList = new List<string>();
XmlNodeList windNodes = xDoc.GetElementsByTagName("windspeed");
for (int i = 0; i < windNodes.Count; i++)
{
windList.Add(windNodes[i].InnerXml); //gives 10 values
}
List<string> tHiList = new List<string>();
XmlNodeList tHiNodes = xDoc.GetElementsByTagName("maxtemperature");
for (int i = 0; i < tHiNodes.Count; i++)
{
tHiList.Add(tHiNodes[i].InnerXml); //gives 10 values
}
List<string> tLoList = new List<string>();
XmlNodeList tLoNodes = xDoc.GetElementsByTagName("mintemperature");
for (int i = 0; i < tLoNodes.Count; i++)
{
tLoList.Add(tLoNodes[i].InnerXml); //gives 10 values
}



Comment