解析 XML 标签内的 CDATA 的最佳方法是什么
我需要在 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 语法的对象的最佳方法是什么
i have the following XML that i need to parse in 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>
into an object called Result
public class Result
{
public int customer_id;
public string customer_first_name;
public string customer_last_name;
}
the one thing that i am trying to determine is how to get rid of the
<![CDATA[]]
and just parse out the regular values.
What is the best way of converting this XML to the object above that will support the CDATA syntax above
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定“解析”是什么意思。如果您使用 XML DOM 解析器(或任何其他类型),那么您可以透明地访问 CDATA 值。
Not sure what you mean by 'parse'. If you use an XML DOM parser (or any other type), then you have transparent access to the CDATA values.
使用 System.XML?尝试XmlCDataSection?
Using System.XML? Try XmlCDataSection?