我想转换这个:
<translation>
1 Sənədlər
</translation>
到
<translation>1 Sənədlər</translation>
在 XML 中使用 C#。
请帮帮我。只有翻译标签。
我试过这个:
XDocument xdoc = XDocument.Load(path);
xdoc.Save("path, SaveOptions.DisableFormatting);
但它不会删除 <translation>
之间的新行标签。
最佳答案
您所拥有的应该可以工作。您可以通过将 XDocument 转储到字符串变量来进行验证,以确认 SaveOptions 是否正在删除格式。
例如:我尝试了以下内容,但内容没有任何格式,包括换行符和空格。
XDocument xmlDoc = new XDocument(new XElement("Team", new XElement("Developer", "Sam")));
var content = xmlDoc.ToString(SaveOptions.DisableFormatting);
关于c# - 在 C# 中用 ""替换新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38655954/