将CDATA xml字符串加载到xmldocument对象中 [英] Loading CDATA xml string into xmldocument object

查看:98
本文介绍了将CDATA xml字符串加载到xmldocument对象中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有以下字符串.

Hi,

I have following string.

<?xml version="1.0" encoding="UTF-8"?>
<response>
    <sessionid><![CDATA[d!l@hD@f!R\R$9jZF%Rk;`0:b@P^n]]>BR082,y\F:|"P6S{bL*`.d+!."\F6&s3%qXzGYBEg8cUI*MPYqtKm"i15O9K1XZ#+1267472380442]]></sessionid>
</response>



我想使用C#将上述字符串加载到xmldocument中,但是我正在获取xmlexception.请给我建议.

谢谢inAdvance.

问候,
Rajesh.M



I want load the above string to xmldocument using C#,but i am getting xmlexception. Please suggest me.

Thanks inAdvance.

Regards,
Rajesh.M

推荐答案

9jZF%Rk;`0:b @ P ^ n ]]> BR082,y \ F:|"P6S {bL *`.d + !." \ F6& s3%qXzGYBEg8cUI * MPYqtKm"i15O9K1XZ#+ 1267472380442]]>> /sessionid < /response >
9jZF%Rk;`0:b@P^n]]>BR082,y\F:|"P6S{bL*`.d+!."\F6&s3%qXzGYBEg8cUI*MPYqtKm"i15O9K1XZ#+1267472380442]]></sessionid> </response>



我想使用C#将上述字符串加载到xmldocument中,但是我正在获取xmlexception.请给我建议.

谢谢inAdvance.

问候,
Rajesh.M



I want load the above string to xmldocument using C#,but i am getting xmlexception. Please suggest me.

Thanks inAdvance.

Regards,
Rajesh.M


因为您有字符]]>在您的字符串中,您需要对字符串进行HTML编码,即使>进入等等.
As you have the characters ]]> in your string you will need to HTML encode the string instead i.e. make > into &gt; etc.




感谢您的答复.但是,当我使用HtmlEncode并尝试加载到xmldocument中时,获得根级别的数据无效.第1行,位置1:"错误. CDATA语法还有另外一件事
如下.


谢谢
Hi,

Thanks for the reply.But When I use the HtmlEncode and trying to loading into xmldocument getting "Data at the root level is invalid. Line 1, position 1:" error. And one more thing the CDATA syntax will be
as follows.


Thanks


这篇关于将CDATA xml字符串加载到xmldocument对象中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆