从给定的XML中完全删除第一个元素
我试图使用powershell完全删除第一个元素,但遇到了问题。寻找任何指针从给定的XML中完全删除第一个元素,xml,powershell,Xml,Powershell,我试图使用powershell完全删除第一个元素,但遇到了问题。寻找任何指针 $SeedTemp_XML.InnerXml是下面的system.XML.xmlnode: <Seed DcFolder="WAN"> <Wiring Action="Add"> <Start DeviceType="" DeviceRegex="" Scope="" ItfNames="" /> <End DeviceType="" DeviceRegex="" Scope
$SeedTemp_XML.InnerXml
是下面的system.XML.xmlnode
:
<Seed DcFolder="WAN">
<Wiring Action="Add">
<Start DeviceType="" DeviceRegex="" Scope="" ItfNames="" />
<End DeviceType="" DeviceRegex="" Scope="" ItfNames="" />
<DevicePattern Scope="Local" />
</Wiring>
<Wiring Action="Add">
<Start DeviceType="Server" DeviceRegex="DeviceA" Scope="Datacenter" ItfNames="" />
<End DeviceType="Server" DeviceRegex="DeviceB" Scope="Datacenter" ItfNames="" />
<DevicePattern Scope="Local" />
</Wiring>
</Seed>
您正在删除
种子的第一个子项的所有子项
要删除种子的第一个子项
,需要执行以下操作:
$SeedTemp\u XML.Seed.RemoveChild($SeedTemp\u XML.Seed.FirstChild)
<Seed DcFolder="WAN">
<Wiring>
</Wiring>
<Wiring Action="Add">
<Start DeviceType="Server" DeviceRegex="DeviceA" Scope="Datacenter" ItfNames="" />
<End DeviceType="Server" DeviceRegex="DeviceB" Scope="Datacenter" ItfNames="" />
<DevicePattern Scope="Local" />
</Wiring>
</Seed>