I've to save xml file in to database after serialising it, this is so that the other Module that uses this sequence to again create the same XML file and use it.
Problem is with my current approach it does it but all in one line. How should I go about so that it create the sequence with correct indentation ?
public static byte[] ConvertXMLToByteArray(XDocument xml)
{
// Init Writers
StringWriter sw = new StringWriter();
XmlTextWriter xw = new XmlTextWriter(sw);
// Save Xml to Text Writer.
xml.WriteTo(xw);
UTF8Encoding encoding = new System.Text.UTF8Encoding(false);
// Convert Xml Document To Byte Array with given encoding
return encoding.GetBytes(sw.ToString());
}