public string GetData(String Zipcode, DateTime date) { weather.ndfdXML myWeather = new weather.ndfdXML(); String xml = myWeather.LatLonListZipCode(Zipcode); //service that retunrs latitude and longitude in an XML string String s = ""; //to extract required data in string format from XML string using (XmlReader reader = XmlReader.Create(new StringReader(xml))) { reader.ReadToFollowing("latLonList"); s = reader.ReadElementContentAsString(); } //Separating latitude and longitude String[] arr = s.Split(','); String lati = arr[0]; String longi = arr[1]; Decimal lat = Convert.ToDecimal(arr[0]); Decimal lon = Convert.ToDecimal(arr[1]); //the funtion returns a string with Weather data we are appending latitude and longitude String st = lati + "|" + longi + "|" + myWeather.NDFDgenByDay(lat, lon, date, "6", "e", "24 hourly"); System.Threading.Thread.Sleep(2000); return(st); }
private void zipBtn_Click(object sender, EventArgs e) { String ZIP = zipBox.Text; weather.ndfdXML weatherServ = new weather.ndfdXML(); String XML = weatherServ.LatLonListZipCode(ZIP); XML = XML.Substring(XML.IndexOf("<latLonList>") + "<latLonList>".Length, XML.IndexOf("</latLonList>") - XML.IndexOf("<latLonList>") - "<latLonList>".Length); coBox.Text = XML; }