Wednesday, September 10, 2008

Converting XMLContent to String

Following code will help you to simply read a XML file and get the content in string object

public string ConvertXMLToString(string xmlFilePath)
{
string xmlOutput = "";
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(xmlFilePath);
if (xmlDocument != null)
{
xmlOutput = xmlDocument.OuterXml.ToString();
}
xmlDocument = null;
return xmlOutput;
}

No comments: