如何从XmlDocument删除空格 [英] How to remove whitespace from an XmlDocument
本文介绍了如何从XmlDocument删除空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个XML文档,我想从中删除空格和回车符。
I have an XML document from which I want to remove white spaces and carriage returns. How can I get the modified XML using C#.
推荐答案
将prepareWhitespace标志设置为false:
Set the preserveWhitespace flag to false:
XmlDocument doc = new XmlDocument();
doc.PreserveWhitespace = false;
doc.Load("foo.xml");
// doc.InnerXml contains no spaces or returns
这篇关于如何从XmlDocument删除空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文