To check whether input string data is XML or NOT.
Simply copy and paste the following code. This code will
throw an exception in case input string is not XML.
if (!String.IsNullOrEmpty(sXMLMessage))
{
try
{
System.Xml.Linq.XElement.Parse(sXMLMessage);
// Business Logic for XML string data here
}
catch
(XmlException ex)
{
// Business Logic for non-xml string data here
}
}
Comments
Post a Comment