如何在 C# 中将字符串解码为 XML 字符串 [英] How to decode string to XML string in C#

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

问题描述

我有一个包含 XML 描述的字符串(来自 CDATA 元素).我需要将此字符串解码为一个新字符串,使用 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#

现有字符串:

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

想要的字符串:

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

推荐答案

  1. HttpUtility.HtmlDecode 来自 System.Web
  2. WebUtility.HtmlDecode 来自 System.Net

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

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