首页 > 其他 > 详细

String escape/unescape into XML

时间:2017-02-21 11:40:51      阅读:105      评论:0      收藏:0      [点我收藏+]

Is there any C# function which could be used to escape and un-escape a string, which could be used to fill in the content of an XML element?

And how to unescape?

?

【解决方案】

public static string XmlEscape(string unescaped)

{

XmlDocument doc = new XmlDocument();

XmlNode node = doc.CreateElement("root");

node.InnerText = unescaped;

return node.InnerXml;

}

?

public static string XmlUnescape(string escaped)

{

XmlDocument doc = new XmlDocument();

XmlNode node = doc.CreateElement("root");

node.InnerXml = escaped;

return node.InnerText;

}

String escape/unescape into XML

原文:http://www.cnblogs.com/time-is-life/p/6423277.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!