We want to retrive penality from Xml tables on WebService.
Our code reads the penalty value from first table and penalty value of the second table,
but at the run time it gives us the first value 2 times instead of resulting 2 different values of two tables.
Does anybody have an idea how should I edit my code to give the result specified higher? This is my code:
void pp_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
XElement resultElements = XElement.Parse(e.Result);
List<StudentPunishment> sp = new List<StudentPunishment>();
studentPunishmentsTables = resultElements.Element("studentPunishmentsTables").Value;
string p = s.penalty;
foreach (XElement nod in resultElements.Elements(@"studentPunishmentsTable"))
{
p = resultElements.Element("studentPunishmentsTable").Element("penalty").Value;
MessageBox.Show(p);
}
}
This code works for me fine.
But remeber to define ‘s’ object instance.
http://prntscr.com/96nbh