使用LINQ to XML从CDATA提取数据 [英] Extracting data from CDATA using LINQ to XML
本文介绍了使用LINQ to XML从CDATA提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下xml文件,并且我尝试使用linq到xml来获取驻留在CDATA部分中的Elements.请提出任何建议.
I have the following xml file and I am trying to use linq to xml to get the Elements which are residing inside the CDATA section. Any suggestions please.
<?xml version = "1.0" encoding = "UTF-8"?>
<result final = "true" transaction-id="84WO" xmlns="http://cp.com/rules/client">
<client id = "CustName'>
<quoteback>
</client>
<report format = "CP XML">
<![CDATA[<?xml version="1.0" encoding = "UTF-8" standalone = "yes"?>
<personal_auto xmlns = "http://cp.com/rules/client">
<admin>
</admin>
<report>
</report>
</personal_auto>
]]>
</report> </result>
推荐答案
XElement XTemp = XElement.Load(YourXMLfile);
var queryCDATAXML = from element in XTemp.DescendantNodes()
where element.NodeType == System.Xml.XmlNodeType.CDATA
select element.Parent.Value.Trim();
这篇关于使用LINQ to XML从CDATA提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文