Decode XML returned by a webservice (< and > are replaced with < and &gt)? [duplicate]

*爱你&永不变心* 提交于 2019-12-01 17:43:14

问题


Possible Duplicate:
How to decode string to XML string in C#

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 &lt; and &gt;.

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 >.

Framework is .NET 3.5


回答1:


You can use HttpServerUtility.HtmlDecode(encodedString) to return the decoded string.

Appropriate msdn link HtmlDecode




回答2:


For some reason HttpServerUtility.HtmlDecode is not exist for me.

Try HttpUtility.HtmlDecode to solve this problem.



来源:https://stackoverflow.com/questions/5006020/decode-xml-returned-by-a-webservice-and-are-replaced-with-lt-and-gt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!