在我的.NET app.config文件如何存储XML值我的、文件、NET、app

由网友(空心)分享简介:我想保存在我的app.config文件的XML值。在app.config不喜欢这样,我不能使用<![CDATA [构建忽略我的价值的XML'ness I am trying to store an xml value in my app.config file. The app.config does no...

我想保存在我的app.config文件的XML值。 在app.config不喜欢这样,我不能使用<![CDATA [构建忽略我的价值的XML'ness

I am trying to store an xml value in my app.config file. The app.config does not like this and I cannot use the <![CDATA[ construct to ignore the XML'ness of my value.

有没有办法做到这一点?

Is there a way to do it?

值例如:&LT; FieldRef名称='LinkfileName'可空='真'/&GT;&LT; FieldRef名称='网络'可空='真'/&GT;

推荐答案

您可以保存XML文档作为文本的属性值,如果你逃跑的字符实体:

You can save an XML document as text in an attribute value if you escape the character entities:

&lt;FieldRef Name=&quot;Linkfilename&quot; ...

您可以再使用XMLDocument.load方法()来解析文本值。

You can then use XmlDocument.Load() to parse the text value.

请注意,这不会对你的榜样工作,因为你的价值是一个XML文档片段,而不是一个格式良好的XML文档。您可能需要将其包装在一个封闭的文档元素(其标记仍会被转义),或使用正确初始化的XmlReader来处理的价值,一旦你已经检索到它从配置。

Note that this won't work for your example because your value is an XML document fragment and not a well-formed XML document. You either need to wrap it in an enclosing document element (whose markup will still be escaped) or use a properly-initialized XmlReader to process the value once you've retrieved it from the configuration.

阅读全文

相关推荐

最新文章