(Using system.IO)
You can simply use \n for newline and \t in front of the string to indent it.
For example in c#:
public string theXML() {
string xml = "";
xml += "\n";
xml += "\t\n";
xml += "\t\n";
xml += "\n";
return xml;
}
This will result in the output:
http://prntscr.com/96dfqc