Exemplo n.º 1
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        ServiceReference1.GlobalWeatherSoapClient gw = new ServiceReference1.GlobalWeatherSoapClient("GlobalWeatherSoap");
        string xml = gw.GetWeather(this.CiudadTextBox.Text, this.PaisTextBox.Text);
        // We load the string in an xml reader to parse it
        XmlReader reader = XmlReader.Create(new System.IO.StringReader(xml));

        reader.MoveToContent();
        // Parse the file and find the values
        string resultado = "";

        while (reader.Read())
        {
            switch (reader.NodeType)
            {
            case XmlNodeType.Element:     // The node is an element.
                resultado += reader.Name + ": ";
                break;

            case XmlNodeType.Text:     //Display the text in each element.
                resultado += reader.Value + "\n";
                break;
            }
        }
        reader.Close();
        this.ResultadosTextBox.Text = resultado;
    }
Exemplo n.º 2
0
        public ActionResult Contacto()
        {
            string temperatura = "";

            try
            {
                ServiceReference1.GlobalWeatherSoapClient client = new ServiceReference1.GlobalWeatherSoapClient("GlobalWeatherSoap");
                string      result = client.GetWeather("Madrid", "Spain");
                XmlDocument xml    = new XmlDocument();
                xml.LoadXml(result);
                XmlNodeList xnList = xml.SelectNodes("/CurrentWeather");

                foreach (XmlNode xn in xnList)
                {
                    temperatura = xn["Temperature"].InnerText;
                }
            }
            catch (Exception ex)
            {
                temperatura = "No disponible";
            }
            ViewBag.Temperatura = temperatura;
            return(View());
        }
Exemplo n.º 3
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     ServiceReference1.GlobalWeatherSoapClient gw = new ServiceReference1.GlobalWeatherSoapClient("GlobalWeatherSoap");
     this.ResultadosTextBox.Text = gw.GetWeather(this.CiudadTextBox.Text, this.PaisTextBox.Text);
 }