Hello, working on a code to read xml, got a hint that i cant use xdocument since not valid characters in the xml.
The purpose of the code is to use the value from he cmblist to find a specifific node and print it in a txt box. Would be very happy for any help :)
The xml :
http://www.yr.no/sted/Norge/Akershus/Nesodden/Fjellstrand/varsel.xml
The code
XDocument xmlDoc = XDocument.Load("C:/Users/Daxal/documents/visual studio 2010/Projects/Yr/Yr/fjellstrand.xml");
var games = from game in xmlDoc.Descendants("weatherdata")
where game.Element("forecast").Element("text").Element("location").Element("time").Attribute("from").Value == cmb_sted.SelectedItem.ToString()
select new
{ Title = game.Element("title").Value,
Body = game.Element("body").Value,
};
txt_result.Text = "";
foreach (var game in games)
{//write values in txt box
txt_result.Text = txt_result.Text + "Title : " + game.Title + "\n";
txt_result.Text = txt_result.Text + "Body : " + game.Body + "\n\n";
}
if (txt_result.Text == "")
txt_result.Text = "No Results.";
Loading
Suthish NairPosted Dec 19, 2010, 2:59 PM
or using System.Web.HttpUtility;Daniel GolanPosted Dec 19, 2010, 3:09 PM
Daniel GolanPosted Dec 19, 2010, 1:54 PM
Error on 'Server'
"The name 'Server' does not exist in the current context"
Console.Write(Server.Current.HtmlDecode(record.Value) + "
");
Suthish NairPosted Dec 19, 2010, 1:47 PM
Daniel GolanPosted Dec 19, 2010, 1:19 PM
At first look i get error at XPathSelectElements and server.
Suthish NairPosted Dec 19, 2010, 11:20 AM
XDocument example, not tested. try it out.
XDocument xDoc = XDocument.Load(Server.MapPath("1.xml")); names = xDoc.XPathSelectElements("weatherdata/forecast/text/location/time").Descendants(); IEnumerable