Here is simple c# extension method to format your XML data. This is useful for logging xml data to trace files, etc: