<?xml version="1.0" encoding="utf-8"?>
<configSections>
----------
----------
</configSections>
<appSettings>
<add key="Name" Value="XXX">
<add key="Age" Value="10">
<!--<add key="Number" value="5"/>--><!--uncomment it-->
<!--<add key="Class" value="10"/>-->
</appSettings>
我想取消注释第一个注释行。
到目前为止,这是我的代码:
foreach (XmlElement xElement in xmlDoc.DocumentElement)
{
if (xElement.Name == "appSettings")
{
foreach (XmlNode xNodes in xElement.ChildNodes)
{
if (xNodes.NodeType == XmlNodeType.Comment)
{
if (xNodes.InnerText.Contains("Number"))
{
// Now the commented line is in xNodes.InnerText.
// How can i add this line in that xml file under appSettings?
}
}
}
break;
}
}