Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从给定的XML中完全删除第一个元素_Xml_Powershell - Fatal编程技术网

从给定的XML中完全删除第一个元素

从给定的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

我试图使用powershell完全删除第一个元素,但遇到了问题。寻找任何指针

$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>