我正在尝试为现有的XML文档添加注释.该文档在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;
Run Code Online (Sandbox Code Playgroud)