本帖最后由 5i365 于 2021-12-25 12:50 编辑
回复 5# idwma
按上面链接的代码, 照葫芦画了两个瓢, 但是还是不能删除, 但是$nod可以取到值:- [xml]$xml = Get-Content '.\xml.xml'
-
- $nod = $xml.SelectSingleNode("//rehearsal[contains(text(), 'ABC')]")
- $nod
-
- [void]$xml.score-partwise.part.measure.RemoveChild($nod.ParentNode)
-
- $xml.Save('.\ok.xml')
复制代码 ------------------------------------------------- $rom, $inp = '.\list.txt', '.\xml.xml'
- ($lst, $xml = (Get-Content $rom), [xml](Get-Content $inp))[0].ForEach{
- $nod = $xml.SelectSingleNode("//rehearsal[contains(text(), '$_')]")
- [void]$xml.score-partwise.part.measure.RemoveChild($nod.ParentNode)
- }
- $xml.Save('.\ok.xml')
复制代码
|