У меня есть текстовое поле, в котором я хочу, чтобы пользователь ввел свой номер woeid, но я не уверен, как добавить его в строку запроса, в приведенном ниже коде я могу получить погоду для Лос-Анджелеса, но сейчас я хочу получить его с помощью номера woeid, предоставленного пользователем.
try
{
String query = String.Format("https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid in (select woeid from geo.places(1) where text='Los Angeles')&format=xml&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys");
var wData = new XmlDocument();
wData.Load(query);
var man = new XmlNamespaceManager(wData.NameTable);
man.AddNamespace("yweather", "http://xml.weather.yahoo.com/ns/rss/1.0");
XmlNode channel = wData.SelectSingleNode("query").SelectSingleNode("results").SelectSingleNode("channel");
XmlNodeList nodes = wData.SelectNodes("query/results/channel");
MainForm.WindSpeed = channel.SelectSingleNode("yweather:wind", man).Attributes["speed"].Value;
MainForm.Town = channel.SelectSingleNode("yweather:location", man).Attributes["city"].Value;
MainForm.Temperature = channel.SelectSingleNode("item").SelectSingleNode("yweather:condition", man).Attributes["temp"].Value;
MainForm.Condition = channel.SelectSingleNode("item").SelectSingleNode("yweather:condition", man).Attributes["text"].Value;
MainForm.Humidity = channel.SelectSingleNode("yweather:atmosphere", man).Attributes["humidity"].Value;
MainForm.TFCond = channel.SelectSingleNode("item").SelectSingleNode("yweather:forecast", man).Attributes["text"].Value;
MainForm.TFHigh = channel.SelectSingleNode("item").SelectSingleNode("yweather:forecast", man).Attributes["high"].Value;
MainForm.TFLow = channel.SelectSingleNode("item").SelectSingleNode("yweather:forecast", man).Attributes["low"].Value;
}
catch {}
}