我试图向现有的XML文档添加注释。当使用XML阅读器(我使用notepad ++)打开文档时,格式完美。但是,当我运行将注释添加到XML顶部的代码时,XML输出为一行。换句话说,所有换行符都已被删除。如何保留我的换行符?
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(doc.Uri);
//This is where I add comments to a string
xmlDoc.DocumentElement.PrependChild(enrichedDoc.CreateComment(comments));
return xmlDoc;