[英]How to escape characters in string in c#
我有這個字符串,並得到一個錯誤
字符串文本 =
<root><Info id="inseID">17</Info><note><123comments></note></root>
我想把它轉換成
<root><Info id="inseID">17</Info><note><123comments></note></root>
使用 linq 到 xml。
var text = "<root><Info id=\"inseID\">17</Info><note></note></root>";
var xml = XElement.Parse(text);
xml.Element("note").Add("<123comments>");
//string result = xml.ToString(); // will be escaped
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.