Just load the XML into an XmlDocument object then write the document using an XmlTextWriter with the indent and whitespace settings you require.