Code to check whether the xml string is well formed or not -
public bool IsValidXml(string xmlContent)
{
var textStream = new StringReader(xmlContent);
using (var xmlTextReader = new XmlTextReader(textStream))
{
try
{
while (xmlTextReader.Read())
{
}
}
catch
{
return false;
}
}
return true;
}