Converting xml to string in C#

Hi friends,
Here is the simple code for converting xml to string.
string strXML = "";
StringReader reader = new StringReader("C:\\test.xml");
XmlDocument doc = new XmlDocument();
doc.Load(reader);
if (doc != null)
{
StringWriter writer = new StringWriter();
doc.Save(writer);
strXML = writer.ToString();
}
doc = null;


...S.VinothkumaR.

3 comments:

Jumanji said...

Thank you, very useful

smcube said...

Thank you very much..!

crispy said...

Which namespace should be used? I cannot use "StringReader" and "StringWriter".