0
다음 함수는 예외가 발생하지 않고 XML 문서가 디스크에 저장된다는 점에서 "작동합니다". 그러나 제거한 노드는 실제로 문서에서 삭제되지 않습니다.XmlNode.RemoveChild는 Powershell에서 아무 효과가 없습니다.
function RemoveInvalidFileNodes($file, $substring){
[xml]$xml = Get-Content $file
$nodes=$xml.SelectNodes("//File")
$substring = [regex]::Escape($substring)
foreach ($node in $nodes) {
if ($node.Name -match $substring)
{
$node.ParentNode.RemoveChild($node)
}
}
Write-Host $xml.OuterXml
$xml.Save
}
나는 몇 시간 동안 내 머리를 두드렸다. 도와주세요!
젠장, 나는 어리 석다. :( –