XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml("<xml><description><![CDATA[木子屋:http://www.mzwu.com/]]></description></xml>");
//读取
Console.WriteLine(xmlDoc.SelectSingleNode("//description").FirstChild.InnerText);
//设置
xmlDoc.SelectSingleNode("//description").FirstChild.InnerText = "谷歌:http://www.g.cn/";
//显示
Console.WriteLine(xmlDoc.InnerXml);XPath没有提供直接获取CDATA 节点的语法,只能变通下,先定位到其父节点,再获取子节点来获取。
评论(0)
暂无评论。