Wednesday, August 17, 2011

How to Read XML Value Using Linq

XDocument xmlDoc = XDocument.Load(Server.MapPath("../App_Code/" + "ReportReady.xml"));
var persons = from ReportSendSMS in xmlDoc.Descendants("Message")
                              select new
                              {
                                  Content = ReportSendSMS.Element("content").Value,
                              };

                string _Message = "";
                foreach (var person in persons)
                {
                    _Message = person.Content.ToString();
                }

No comments:

Post a Comment