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.
我试图在app.config文件中存储一个xml值。配置不喜欢这个,我不能使用构造以忽略我的值的XML性质。</p>
Is there a way to do it?
有办法吗?
Value example:<FieldRef Name='LinkfileName' Nullable='True'/><FieldRef Name='Web' Nullable='True'/>
值示例:
1 个解决方案
#1
6
You can save an XML document as text in an attribute value if you escape the character entities:
如果您转义字符实体,可以将XML文档保存为属性值中的文本:
<FieldRef Name="Linkfilename" ...
You can then use XmlDocument.Load() to parse the text value.
然后可以使用XmlDocument.Load()解析文本值。
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.
注意,这对您的示例不起作用,因为您的值是XML文档片段,而不是格式良好的XML文档。您需要将它封装在一个封装的文档元素中(该元素的标记仍将被转义),或者使用一个初始化良好的XmlReader来处理从配置中检索到的值。
#1
6
You can save an XML document as text in an attribute value if you escape the character entities:
如果您转义字符实体,可以将XML文档保存为属性值中的文本:
<FieldRef Name="Linkfilename" ...
You can then use XmlDocument.Load() to parse the text value.
然后可以使用XmlDocument.Load()解析文本值。
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.
注意,这对您的示例不起作用,因为您的值是XML文档片段,而不是格式良好的XML文档。您需要将它封装在一个封装的文档元素中(该元素的标记仍将被转义),或者使用一个初始化良好的XmlReader来处理从配置中检索到的值。