8/16/2012

C# convert document to string type.

Hi Guys,
There was a situation in my project where I have to convert a xml document to string type, initially I though it is very difficult, and later I felt  it is a cake-walk actually!, the below code snippet shows how to achieve it:



  • First you create a XmlDocument object, then you load the content of the xml document file into the object , where 'file' is the path of the xml file.
  • Create a stringwriter , and save the contnet of xmldocument object into the string writer 'sw'
  • Convert the string writer 'sw' to string and store it in a string variable.

No comments:

Post a Comment