@echo off
setlocal enabledelayedexpansion
for /f "delims=▓ tokens=* eol=▓" %%a in (B.xml) do (
set "ln=%%a"
set "t=!ln!"
set "t=!t:Bill Code=a!"
if "!t!" neq "!ln!" (
set "ln=!ln:^<=^^ set "ln=!ln:^>=^^>!"
echo !ln!>>temp1.tmp
)
)
set ctr=0
for /f "delims=▓ tokens=* eol=▓" %%a in (A.xml) do (
set "ln=%%a"
set "t=!ln!"
set "t=!t:Bill Code=a!"
if "!t!" neq "!ln!" (
set read=false
set /a ctr+=1
set ctr2=0
for /f "delims=▓ tokens=* eol=▓" %%b in (temp1.tmp) do (
set /a ctr2+=1
if !read!==false if "!ctr!"=="!ctr2!" (
set "ln=%%b"
set read=true
)
)
)
set "ln=!ln:^<=^^ set "ln=!ln:^>=^^>!"
echo !ln!>>temp2.tmp
)
del /f /q A.xml
rename temp2.tmp A.xml
del /f /q temp1.tmp
echo Done.
pause
把它放在xml文件旁运行,它会把A.xml中带有bill code关键字的行整行替换成B.xml中对应的一整行。
运行前请做好原文件的备份。