I want to loop through a xml file and display the values in text box, but my textbox is showing only one value at a time. In debug mode I am able to see all values. Here is my code.
void timer1_Tick(object sender, EventArgs e)
{
XDocument xd = XDocument.Load(@"D:\satish1\na.xml");
var query = from p in xd.Descendants("item")
select new
{
//name = p.Element("title").Value,
des = p.Element("description").Value
};
foreach (var p in query)
{
//tbs.Text = p.name.ToString();
title.Text = p.des.ToString();
}
}
How would I repeat all the values continously; my timer’s TimeSpan is 5 seconds.
You are using foreach, hence when ever your code exits the function, you will have only last value assigned to the text box. Do something like this:
Hope this helps.