I have a slight problem with XML. Tried to create an application which could show temperatures in different cities.
This is my XML table:
What I must do, is:
1. Get the temperature from each server, based on the search node
2. write it out.
I know how to get the 'responsedoc' and get the data from the server, I just don't know how to get the responsedoc for each one of these servers separately.
My code looks like this:
XmlNodeList urls = serverDoc.SelectNodes("//servers/server");
string id1 = "1;
string id2 = "2";
string id3 = "3";
foreach(XmlNode node in urls)
string server1 = node.Attributes["name"].InnerText; //Get the attribute name
//Check if attribute value matches the 'id' provided before foreach.
if (server1 == name1)
//Create new node list, so we can get the server url.
XmlNodeList urls2 = serverDoc.SelectNodes("
foreach (XmlNode node2 in urls2)
var serverPath = temp.InnerText;
WebRequest request = WebRequest.Create(node2["url"].InnerText);
var response = request.GetResponse();
Stream stream = response.GetResponseStream();
XmlDocument responseDoc = new XmlDocument();
var tempOut = responseDoc.SelectSingleNode(serverPath);
string temperature = tempOut.Attributes["value"].Value;
Because of this, I'm getting the same temperature for all the other servers, but I need different values for each (obvious). Might be something wrong with my code, but I'm not sure.