【问题标题】:what is the best way to parse out CDATA inside XML tags解析 XML 标记内的 CDATA 的最佳方法是什么
【发布时间】:2011-08-22 22:12:58
【问题描述】:

我有以下需要在 C# 中解析的 XML:

<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 语法的上述对象的最佳方法是什么

【问题讨论】:

    标签: c# xml parsing c#-4.0 xml-parsing


    【解决方案1】:

    不确定您所说的“解析”是什么意思。如果您使用 XML DOM 解析器(或任何其他类型),那么您可以透明地访问 CDATA 值。

    【讨论】:

      【解决方案2】:

      使用 System.XML?试试XmlCDataSection

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-11-25
        • 2015-06-14
        • 2010-10-28
        • 1970-01-01
        • 1970-01-01
        • 2011-12-08
        • 2018-01-17
        • 2019-09-16
        相关资源
        最近更新 更多