<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
我有一个 web.config 文件,其中包含配置标记中的 xmlns。
我想删除一个特定的节点。但我无法读取此文件。
下面是代码:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(PATH + WEB_CONFIG_PATH);
//XmlNode t = xmlDoc.SelectSingleNode("/system.webServer/handlers /add[@path='Reserved.ReportViewerWebControl.axd']");
XmlNode t = xmlDoc.SelectSingleNode("/configuration/system.webServer");
if (t != null)
{
t.ParentNode.RemoveChild(t);
xmlDoc.Save(PATH + WEB_CONFIG_PATH);
}
如果我从配置标记中删除 xmlns,则此代码可以正常工作。
请提供一些解决方案,以便在存在 xmlns 时此代码可以工作。