简体   繁体   English

CDATA xml解析

[英]CDATA xml parsing

I am getting response in xml format and data are inside cData section in xml nodes. 我得到xml格式的响应,数据位于xml节点的cData部分中。 now when i am trying to extract node value then getting value with cdata text. 现在,当我尝试提取节点值,然后使用cdata文本获取值时。

how can i parse it? 我该如何解析?

xml: xml:

<myrecords>
<record>
<id><![CDATA[8683]]></id>
<tempid><![CDATA[4567]]></id>
<type><![CDATA[db]]></type>   
<params>  
<![CDATA[<db>   <dbid>254</dbid>     <isdb>true</isdb>   <mydb>sample</mydb>    </db>]]>
</params>  
</record>
</myrecords>

i used code to get entire list but i need to get only particular node 我使用代码来获取整个列表,但我只需要获取特定的节点

 foreach (var child in xdoc.Root.Elements())
            {                   
                    Console.WriteLine("{0}{1}",child.Name,child.Value);
                    }

the above code list all the cdata value.. 上面的代码列出了所有的cdata值。

i need to get only dbid,isdb,mydb values from the above xml 我只需要从上面的xml中获取dbid,isdb,mydb值

For the "outer" Xml document, the value is nothing but character data. 对于“外部” Xml文档,该值不过是字符数据。 You'll have to parse that value separately if you want to treat it as Xml. 如果要将其视为Xml,则必须分别解析该值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM