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;

}

相关文章:

  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2021-11-19
  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
猜你喜欢
  • 2022-02-10
  • 2022-12-23
  • 2021-09-13
  • 2022-12-23
  • 2021-06-06
  • 2022-12-23
  • 2021-10-02
相关资源
相似解决方案