使用c#

时间:2016-11-15 10:15:47

标签: c# xml

我有一个XML文件,其内容如下所示

<?xml version="1.0" encoding="UTF-8"?>
<Module path="/Automated Meter Reader - sample 1/01 Requirements/System Requirements" Baseline="current" Module_ID="00000080">
<ObjectIdentifier value="AMR-SR-1">
<Attribute name="ParentID" value="Level 1"/>
<Attribute name="custom 1" value="custom value <special value> custom value"/>
</ObjectIdentifier>
</Module>

在上面的XML数据中

<Attribute name="custom 1" value="custom value <special value> custom value"/>

具有转义字符,即&lt;和&gt;
我想处理属性值内的所有转义字符。属性值在双引号内指定。 XML结构是固定的,属性值根据生成XML的文档而不同 我一直在寻找获取XML的属性值,但如果我想使用C#的XML函数,我们需要拥有有效的XML

e.g. string attributeValue = chldNode.Attributes["Name"].Value;

请指导我如何处理上述用例的转义字符。
我已经提到过的链接 How to read attribute value from XmlNode in C#?
String escape into XML
Getting attribute value of an XML Document using C#
Read XML Attribute using XmlDocument

0 个答案:

没有答案