/// <summary> /// Gets weather from service for Country and City /// </summary> /// <param name="Country"></param> /// <param name="City"></param> /// <returns></returns> public string GetWeather(string Country, string City) { WeatherServiceClient.net.webservicex.www.GlobalWeather client = new WeatherServiceClient.net.webservicex.www.GlobalWeather(); StringBuilder sb = new StringBuilder(); string xmlStr = client.GetWeather(City, Country); XmlDocument xmlDoc = new XmlDocument(); //Load the xml string data into xml document xmlDoc.LoadXml(xmlStr); bool success = false; XmlNode xmlNode = xmlDoc.DocumentElement; foreach (XmlNode node in xmlNode.ChildNodes) { if (node.Name == "Status") { success = node.InnerText == "Success"; } else { //Loop through the nodes and put the information in the StringBuilder object. sb.Append("<b>" + node.Name + ":</b> " + node.InnerText + "<br />"); } } if (success) { return(sb.ToString()); } else { return("Data Not Found"); } }
/// <summary> /// Gets weather from service for Country and City /// </summary> /// <param name="Country"></param> /// <param name="City"></param> /// <returns></returns> public string GetWeather(string Country, string City) { WeatherServiceClient.net.webservicex.www.GlobalWeather client = new WeatherServiceClient.net.webservicex.www.GlobalWeather(); StringBuilder sb = new StringBuilder(); string xmlStr = client.GetWeather(City, Country); XmlDocument xmlDoc = new XmlDocument(); //Load the xml string data into xml document xmlDoc.LoadXml(xmlStr); bool success = false; XmlNode xmlNode = xmlDoc.DocumentElement; foreach (XmlNode node in xmlNode.ChildNodes) { if (node.Name == "Status") { success = node.InnerText == "Success"; } else { //Loop through the nodes and put the information in the StringBuilder object. sb.Append("<b>" + node.Name + ":</b> " + node.InnerText + "<br />"); } } if (success) { return sb.ToString(); } else { return "Data Not Found"; } }