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();
                }

String Replace With Multiple Char

using System.Text.RegularExpressions;

_Message = Regex.Replace(_Message, @"[\n\t ]", String.Empty);