how to get the temporature from this webservice?

I am trying to coonect to this webservice:

http://www.webservicex.net/globalweather.asmx WSDL

using this code:

net.webservicex.www.GlobalWeather getWeatherToday = new WindowsApplication1.net.webservicex.www.GlobalWeather();

txtTemp.Text = getWeatherToday.GetWeather("Bahrain International Airport", "Bahrain");

but i need to get the temporature only not the whole xml data in the textbox..




Answer this question

how to get the temporature from this webservice?

  • JGttttt

    thank you very much but after all i didn't like this webservice because it outputs the temperature as

    96 F (36 C)

    but I just need 36 (without C)

    Thanks again...



  • PublicError

    I would use a xmlTextReader to get the temperature

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    using System.Xml;

    namespace WeatherWS
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
    WeatherService.GlobalWeather ws = new WeatherService.GlobalWeather();
    String strWeather = ws.GetWeather("Bahrain International Airport", "Bahrain");

    TextReader tx = new StringReader(strWeather);

    XmlTextReader reader = new XmlTextReader(tx);
    String strNode = "";

    while (reader.Read())
    {
    switch (reader.NodeType)
    {
    case XmlNodeType.Element:
    strNode = reader.Name;
    break;
    case XmlNodeType.Text:
    if (strNode == "Temperature")
    {
    textBox1.Text = reader.Value;
    }
    break;
    }
    }
    }
    }
    }



  • how to get the temporature from this webservice?