解析XML标记中的CDATA的最佳方法是什么

本文关键字:CDATA 最佳 方法 是什么 XML 解析 | 更新日期: 2023-09-27 18:06:34

我有以下XML,我需要在c#中解析:

<data>
  <customer_id><![CDATA[1414301]]></customer_id>
  <last_modified_date><![CDATA[2011-08-14 11:58:58]]></last_modified_date>
  <customer_first_name><![CDATA[joe]]></customer_first_name>
  <customer_last_name><![CDATA[blow]]></customer_last_name>
</data>

放入名为Result

的对象中
public class Result
{
  public int customer_id;
  public string customer_first_name;
  public string customer_last_name;
}
我想确定的一件事是如何去掉
 <![CDATA[]]

,然后解析出常规值。

将这个XML转换为上面支持CDATA语法的对象的最佳方法是什么

解析XML标记中的CDATA的最佳方法是什么

不知道你说的" parse "是什么意思。如果使用XML DOM解析器(或任何其他类型),则可以透明地访问CDATA值。

使用System.XML?试试XmlCDataSection ?