How make XMLDocument do not put spaces on self-closed tags?

折月煮酒 提交于 2019-12-05 06:08:35

There is no space before the closing "/" in the XmlDocument. XmlDocument is a data structure consisting of nodes. It is binary. It is not text.

Any extra space you are seeing exists only when you serialize the document as text.

Are you actually having a problem with signing, or do you only think you will have such a problem?

I have had this problem before. XML signed by a basic Hash so it can't change when serialized. I solved it by writing a serializer so that I could be sure that it would output the correct XML.

The basic recipe is to Read the XML with a XMLReader, and write out each chunk as it comes.

Try this:

XMLDocument doc;

...

string XMLstring = doc.OuterXml.Replace(" />","/>");

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!