XML删除节点(如果存在)和SelectSingleNode
我尝试构建一个powershell脚本,如果存在某个节点,该脚本将从我的web.config文件中删除该节点。 我有以下xml结构XML删除节点(如果存在)和SelectSingleNode,xml,powershell,Xml,Powershell,我尝试构建一个powershell脚本,如果存在某个节点,该脚本将从我的web.config文件中删除该节点。 我有以下xml结构 <configuration> <configSections> <sectionGroup name="common"> <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging,
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging, Version=2.1.2.0, Culture=neutral, PublicKeyToken=af08829b84f0328e" />
</sectionGroup>
</configSections>
</configuration>
但是,找不到该节点,因此未删除该节点。
你能帮我得到正确的命令吗
多谢各位
在其他的标准中,我们正在寻找一个元素,而这个元素并不存在
你是想用
/configuration/configSections/sectionGroup[@name='common']
?
注意,与XML文档的根元素一样,在表达式开头使用//只能减慢速度。如何定义$SectionGroupNode?
//configuration/configSections/sectionGroup/add[@name='common']
/configuration/configSections/sectionGroup[@name='common']