是否也可以在从 xml 文件中删除其他重复项时忽略一些重复行,例如:如果我的 abx.xml 是 CODE:
@echo off
setlocal disableDelayedExpansion
set "file=%~1"
set "line=%file%.line"
set "deduped=%file%.deduped"
::Define a variable containing a linefeed character
set LF=^
::The 2 blank lines above are critical, do not remove
>"%deduped%" (
for /f usebackq^ eol^=^%LF%%LF%^ delims^= %%A in ("%file%") do (
set "ln=%%A"
setlocal enableDelayedExpansion
>"%line%" (echo !ln:\=\\!)
>nul findstr /xlg:"%line%" "%deduped%" || (echo !ln!)
endlocal
)
)
>nul move /y "%deduped%" "%file%"
2>nul del "%line%"
请只提供批处理脚本。
<bookstores>
<book id="parent">
<name="it1"/>
<name="it1"/>
<name="it2"/>
</book>
<book id="child">
<name="it1"/>
<name="it1"/>
<name="it2"/>
<name="it3"/>
</book>
</bookstores>
输出应该是:
<bookstores>
<book id="parent">
<name="it1"/>
<name="it2"/>
</book>
<book id="child">
<name="it3"/>
</book>
</bookstores>
但我得到的输出是:
注意: </book>
标签已删除。
<bookstores>
<book id="parent">
<name="it1"/>
<name="it2"/>
</book>
<book id="child">
<name="it3"/>
</bookstores>
我搜索了几个类似的请求,但其中大多数都删除了所有重复的行,但不确定如何忽略一些重复的行: