level 1
节奏过人就是牛
楼主
请教BAT脚本替换XML节点,会把!都替换掉的解决办法
原始文本(只列一部分,其他省略)
<?xml version="1.0" encoding="Windows-1252" ?>
<NotepadPlus>
<GUIConfigs>
<!-- 3 status : "large", "small" or "hide"-->
<GUIConfig name="ToolBar" visible="yes">standard</GUIConfig>
<!-- 2 status : "show" or "hide"-->
运行脚本后,如第四行的!--都被替换掉了,还有:也被替换掉了
<?xml version="1.0" encoding="Windows-1252" ?>
<NotepadPlus>
<GUIConfigs>
< "large", "small" or "hide"-->
<GUIConfig name="ToolBar" visible="yes">modify</GUIConfig>
< "show" or "hide"-->
附原始代码
@echo off
set filename=C:\11.xml
set oldstr=standard
set newstr=modify
setlocal enabledelayedexpansion
rem for /f "delims=" %%a in (%filename%) do (
for /f "delims=" %%a in ('findstr /n .* %filename%') do (
set aa=%%a
set aa=!aa:%oldstr%=%newstr%!
set aa=!aa:*:=!
echo;!aa!>>"%filename%.tmp"
rem echo !aa!>>"%filename%.tmp"
)
move "%filename%.tmp" "%filename%"
pause
2014年01月21日 16点01分
1
原始文本(只列一部分,其他省略)
<?xml version="1.0" encoding="Windows-1252" ?>
<NotepadPlus>
<GUIConfigs>
<!-- 3 status : "large", "small" or "hide"-->
<GUIConfig name="ToolBar" visible="yes">standard</GUIConfig>
<!-- 2 status : "show" or "hide"-->
运行脚本后,如第四行的!--都被替换掉了,还有:也被替换掉了
<?xml version="1.0" encoding="Windows-1252" ?>
<NotepadPlus>
<GUIConfigs>
< "large", "small" or "hide"-->
<GUIConfig name="ToolBar" visible="yes">modify</GUIConfig>
< "show" or "hide"-->
附原始代码
@echo off
set filename=C:\11.xml
set oldstr=standard
set newstr=modify
setlocal enabledelayedexpansion
rem for /f "delims=" %%a in (%filename%) do (
for /f "delims=" %%a in ('findstr /n .* %filename%') do (
set aa=%%a
set aa=!aa:%oldstr%=%newstr%!
set aa=!aa:*:=!
echo;!aa!>>"%filename%.tmp"
rem echo !aa!>>"%filename%.tmp"
)
move "%filename%.tmp" "%filename%"
pause