1.XML 代码
<?
xml version="1.0" encoding="utf-8"
?>
<
net_lover
>
<
sitename
>
<![CDATA[
<h2>.NET 开发</h2>
]]>
</
sitename
>
<
siteurl
>
http://dotnet.aspx.cc
</
siteurl
>
</
net_lover
>
我们可以采用下面的方法修改 CDATA 节点的内容。
C# 代码
System.Xml.XmlDocument d
=
new
System.Xml.XmlDocument();
d.Load(Server.MapPath(
"
~/1.xml
"
));
System.Xml.XmlCDataSection n
=
d.SelectSingleNode(
"
/net_lover/sitename
"
).FirstChild
as
System.Xml.XmlCDataSection;
n.Value
=
"
<h1>.NET 开发</h1>
"
;
d.Save(Server.MapPath(
"
~/2.xml
"
));