在我的.NET app.config文件如何存储XML值 [英] How do I store an XML value in my .NET App.Config file

查看:129
本文介绍了在我的.NET app.config文件如何存储XML值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想保存在我的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.

这篇关于在我的.NET app.config文件如何存储XML值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆