德code XML返回一个Web服务(LT;和&gt;替换为&放大器; LT;和&放大器; GT)? [英] Decode XML returned by a webservice (< and > are replaced with &lt; and &gt)?
问题描述
可能重复:
如何去code字符串在C# XML字符串
Possible Duplicate:
How to decode string to XML string in C#
我打电话一个web服务返回的XML。如果我使用SOAP,一切都很好,我得到有效的XML回来。然而,如果我使用POST得到的返回值,在XML到达EN codeD作为响应的内容。
这意味着,所有的&LT;和>被替换为&放大器; LT;
和&放大器; GT;
I'm calling a webservice which returns XML. If I'm using SOAP, all is fine, I get valid XML back. If however I use POST to get the return value, the XML arrives encoded as the content of the response.
This means, all < and > are replaced with <
and >
.
有没有办法将字符串转换回有效的XML?我不想使用正则表达式或手动更换,因为我敢肯定,有一些其他的字符已经连接codeD之外的&lt;和>。
Is there a way to convert the string back into valid XML? I don't want to use a RegEx or to replace manually since I'm sure that there are a couple of other characters that have been encoded besides the < and >.
框架是.NET 3.5
Framework is .NET 3.5
推荐答案
您可以使用 HttpServerUtility.HtmlDe code(EN codedString)
返回德codeD字符串。
You can use HttpServerUtility.HtmlDecode(encodedString)
to return the decoded string.
相应的MSDN链接 HtmlDe code
这篇关于德code XML返回一个Web服务(LT;和&gt;替换为&放大器; LT;和&放大器; GT)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!