我们可以强制的XmlWriter发行&LT

我们可以强制的XmlWriter发行&LT

本文介绍了我们可以强制的XmlWriter发行<我的标签>< /我的标签>而不是<我的标签/>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在默认情况下,

someXmlWriter.WriteElementString("my-tag", someString);

生成<我的标签/>

我看了看周围的XmlWriterSettings类可能的选择,这将迫使作家产生<我的标签>< /我的标签> 来代替,但没有发现任何东西。

I looked around XmlWriterSettings class for possible options that would force the writer to produce <my-tag></my-tag> instead but didn't find anything.

是否有强迫XmlWriter要发出带有开放标签,关闭标签,而不是用简写形式?

Is there a simple way of forcing the XmlWriter to issuing empty elements with "open tag, close tag" rather than with the short-hand form?

修改
是!我知道有关于XML有效性两种表示法是等价的,有效的和所有......我可是正与传统的code这在节点级解析),XML等使用读(即(!),并摸索的东西由阅读() - 荷兰国际集团在空节点上...

Edit:
Yes! I realize that with regards to XML validity the two notations are equivalent, valid and all... I'm however working with legacy code which parses such XML using Read(), i.e. at node level (!) and fumbles things up by Read()-ing when on an empty node...

因此​​,我的问题涉及在限制变化量相对于此遗留code的范围内。这个问题确实与this SO质疑的建议;这些选择提供有但是很容易适用于我的情况。

Hence my question comes in the context of limiting the amount of changes to this legacy code. The question is indeed overlapping with this SO question as suggested; none of the options offered there are however easily applicable to my situation.

推荐答案

没有选项设置为做到这一点在.NET。他们是同样的事情,任何解析器应该能够处理有效的XML。

There is no option setting to do that in .Net. They are the same thing and any parser should be able to handle valid XML.

这篇关于我们可以强制的XmlWriter发行&LT;我的标签&GT;&LT; /我的标签&GT;而不是&LT;我的标签/&GT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 02:07