My Controller
// Get Weather Yahoo Api Data
//
XmlDocument doc = new XmlDocument();
// Load data
doc.Load("http://ift.tt/1rmpHtY");
// Set up namespace manager for XPath
XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable);
ns.AddNamespace("yweather", "http://ift.tt/NpgW1h");
// Get forecast with XPath
XmlNodeList nodes = doc.SelectNodes("/rss/channel/item/yweather:condition", ns);
//List<ListItem> _returnList = new List<ListItem>();
//var nodees = new List<XmlNode>(nodes.Cast<XmlNode>());
List<string> hh=new List<string>();
foreach (XmlNode node in nodes)
{
//hh.Add(node.Attributes["text"].InnerText);
//hh.Add(node.Attributes["temp"].InnerText);
//hh.Add(node.Attributes["date"].InnerText);
hm.w_text = node.Attributes["text"].InnerText;
hm.w_temp = node.Attributes["temp"].InnerText;
hm.w_date = node.Attributes["date"].InnerText;
//Response.Write(node.Attributes["text"].InnerText);
//Response.Write(node.Attributes["temp"].InnerText);
//Response.Write(node.Attributes["date"].InnerText);
}
nodes = doc.SelectNodes("/rss/channel/item/yweather:forecast", ns);
foreach (XmlNode node in nodes)
{
//hh.Add("{0}: {1}, {2}F - {3}F");
//hh.Add(node.Attributes["day"].InnerText);
//hh.Add(node.Attributes["text"].InnerText);
//hh.Add(node.Attributes["low"].InnerText);
//hh.Add(node.Attributes["high"].InnerText);
hm.w_day = node.Attributes["day"].InnerText;
hm.w_text2 = node.Attributes["text"].InnerText;
hm.w_low = node.Attributes["low"].InnerText;
hm.w_high = node.Attributes["high"].InnerText;
//Response.Write("{0}: {1}, {2}F - {3}F");ss
//Response.Write(node.Attributes["day"].InnerText);
//Response.Write(node.Attributes["text"].InnerText);
//Response.Write(node.Attributes["low"].InnerText);
//Response.Write(node.Attributes["high"].InnerText);
}
hm.weatherNode = hh;
hm.HomeModelennum = Horizontal;
return View("Home", "~/Views/Shared/_Nobat.cshtml", hm);
}
My View
<tr>
@foreach (var item in Model.HomeModelennum)
{
<td>@item.w_temp.ToString()</td>
<td>@item.w_date</td>
<td>@item.w_day</td>
<td>@item.w_text2</td>
<td>@item.w_low</td>
<td>@item.w_high</td>
<td>@item.weatherstring</td>
<img src="@item.w_img" width="57" height="100" >
}
</tr>
When i assigned in view the data is not shown
the error is displayed below
An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
I am returning data completely from yahoo weather API
No comments:
Post a Comment