如何去code字符串在C#中的XML字符串 [英] How to decode string to XML string in C#

查看:151
本文介绍了如何去code字符串在C#中的XML字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串(从CDATA元素),其中包含的XML描述。我需要去$ C C此字符串$成显示正确使用C#字符的新字符串

现有的字符串:

 &放大器; LT; XML版本=1.0编码=UTF-8独立=是与放大器; GT;&放大器; LT; myreport xmlns="http://test.com/rules/client"><admin><ordernumber>123</ordernumber><state>NY</state></report></myreport>
 

字符串通缉:

 < XML版本=1.0编码=UTF-8独立=是&GT?;
< myreport的xmlns =htt​​p://test.com/rules/client>
<admin><ordernumber>123</ordernumber><state>NY</state></report></myreport>
 

解决方案

看<一href="http://msdn.microsoft.com/en-us/library/system.web.httputility.htmlde$c$c.aspx"><$c$c>HttpUtility.HtmlDe$c$c方法。

I have a string (from a CDATA element) that contains description of XML. I need to decode this string into a new string that displays the characters correctly using C#

Existing String:

&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;&lt;myreport xmlns="http://test.com/rules/client"&gt;&lt;admin&gt;&lt;ordernumber&gt;123&lt;/ordernumber&gt;&lt;state&gt;NY&lt;/state&gt;&lt;/report&gt;&lt;/myreport&gt;

String Wanted:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<myreport xmlns="http://test.com/rules/client">
<admin><ordernumber>123</ordernumber><state>NY</state></report></myreport>

解决方案

Look at HttpUtility.HtmlDecode method.

这篇关于如何去code字符串在C#中的XML字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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