[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. (type a.xml) -join '' -replace '\s+<direction.*>ABC<.*?/direction>','' -replace '>\s',">`r`n"
复制代码

TOP

回复 3# 5i365

不稳吗?正则挻通用的万金油
  1. $a=type a.xml
  2. $ofs="`n"
  3. "$a" -replace '\s*<direction[\s\S]*>ABC<[\s\S]*?/direction>',''
复制代码

TOP

本帖最后由 idwma 于 2021-12-26 15:03 编辑

回复 11# 5i365
  1. sc b.xml ([io.file]::ReadAllText("a.xml") -replace '\s*<direction.*>[\r\n\s]*<.*>ABC<[\s\S]*?/direction>','')
复制代码

TOP

本帖最后由 idwma 于 2021-12-26 17:48 编辑

回复 10# 5i365
  1. https://docs.microsoft.com/zh-cn/previous-versions/dotnet/netframework-4.0/ms256086(v=vs.100)
复制代码
  1. [xml]$a=type a.xml
  2. $b=$a.SelectSingleNode("//descendant::direction[direction-type/rehearsal='ABC']")
  3. $b.ParentNode.RemoveChild($b)
  4. $a.save("b.xml")
复制代码

TOP

回复 14# 5i365

那这样呢,不需要知道节点的信息了
  1. $a="\s*<.*>[\r\n\s]*<.*>[\r\n\s]*<.*>ABC<.*>[\r\n\s]*<.*>[\r\n\s]*<.*>"
  2. sc b.xml ([io.file]::ReadAllText("a.xml") -replace "$a",'')  -encoding utf8
复制代码

TOP

回复 17# 5i365

那这样呢
  1. $test = @'
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <score-partwise version="3.1">
  4.   <part id="P1">
  5.     <measure number="1" width="118.81">
  6.       <direction placement="above">
  7.         <direction-type>
  8.           <rehearsal default-x="-20.55" relative-y="30.00" font-weight="bold" font-size="14">ABC</rehearsal>
  9.           </direction-type>
  10.         </direction>
  11.       <direction placement="above">
  12.         <direction-type>
  13.           <rehearsal default-x="-40.55" relative-y="60.00" font-weight="bold" font-size="14">CDE</rehearsal>
  14.           </direction-type>
  15.         </direction>
  16.       </measure>
  17.     </part>
  18.   </score-partwise>
  19. '@
  20. [xml]$a = $test
  21. $b = $a.SelectSingleNode("//*[./.='ABC']")
  22. $b.ParentNode.RemoveChild($b)
  23. $a.save("b.xml")
复制代码

TOP

回复 23# 5i365


    ps 2.0,试了可以删两层

TOP

回复 27# 5i365


    又解锁了新支线任务什么是dtd文件

TOP

回复 29# 5i365


   技穷了,这个乐谱文件解析时还出错

TOP

回复 35# 5i365
  1. $a.SelectSingleNode("//*[*/rehearsal='A']")
复制代码
1

评分人数

    • 5i365: 牛X 多谢, 这回感觉应该稳了技术 + 1

TOP

回复 37# 5i365

搜一下就有了照抄了
     https://developer.mozilla.org/en ... Functions/translate
  1. $a.SelectSingleNode("//*[*/rehearsal=translate('a', 'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')]")
复制代码

TOP

返回列表