gpt4 book ai didi

linq-to-xml - 使用 LINQ to XML 从 CDATA 中提取数据

转载 作者:行者123 更新时间:2023-11-30 23:59:04 24 4
gpt4 key购买 nike

我有以下 xml 文件,我正在尝试使用 linq to xml 来获取驻留在 CDATA 部分中的元素。请提出任何建议。

<?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 - 使用 LINQ to XML 从 CDATA 中提取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3720076/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com