如何在 C#、.NET 1.1 中删除 XmlDocument 的结束标记? [英] How to remove closing tag of an XmlDocument in C#, .NET 1.1?
问题描述
如何删除 XML 文档中元素 c 的结束标记?
How can I remove the closing tag of element c in a XML document?
转换后的 XML 将通过架构验证并被拒绝,因为其中包含空格.我正在使用 C#、.NET 1.1(我正在更新旧应用程序 :-( ).
The converted XML will go through a schema validation and it is rejected because it has a whitespace within. I'm using C#, .NET 1.1 (I'm updating a legacy application :-( ).
注意:我不能通过字符串操作来转换 XML 文档.
Note: I must not resort to string manipulation to convert the XML document.
当前:
<main>
<a>
<b />
<c>
</c>
</a>
</main>
决赛:
<main>
<a>
<b />
<c />
</a>
</main>
更新 1:有关其他详细信息,最终的 XML 文档被保存为文件,然后另一个过程验证该文件.保存的 XML 似乎已格式化.
Update 1: for additional details, the final XML document is saved as file, and then another process validates the file. It appears that the saved XML is formatted.
我不确定这是否属实:
<a></a> == <a />
推荐答案
也许将 InnerText 设置为 null 而不是 string.Empty 会有帮助吗?
更新.或者只是设置 XmlElement.IsEmpty )
Update. Or just set XmlElement.IsEmpty )
这篇关于如何在 C#、.NET 1.1 中删除 XmlDocument 的结束标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!