bat修改xml节点值后,在文件最后多了一个空行,如何解决

雨雪纷纷 2018-12-26 01:18:54
在执行bat之前,xml文件中是没有多余的空行,执行后就多了一个行出来了,如下图:
修改前:

修改后:


bat代码:
@echo off
setlocal enabledelayedexpansion


set fileName=D:\打包\Terminal\Config
cd /d %fileName%

for /f "skip=2 tokens=1-4 delims=^<^>" %%i in ('find /i "LossVersion" Config.xml') do (
set LossVersion=%%k
echo LossVersion当前值为!LossVersion!
)

for /f "skip=2 tokens=1-4 delims=^<^>" %%i in ('find /i "AppVersion" Config.xml') do (
set AppVersion=%%k
set /p str2=AppVersion修改为(当前值为:!AppVersion!):
)

chcp 65001

for /f "tokens=* delims=" %%a in (Config.xml) do (
set "content=%%a"
call set "content=%%content:<AppVersion>!AppVersion!</AppVersion>=<AppVersion>!str2!</AppVersion>%%"
call set "content=%%content:<LossVersion>!LossVersion!</LossVersion>=<LossVersion>!str2!</LossVersion>%%"
echo !content!>>result.xml
)
del Config.xml
ren result.xml Config.xml
chcp 936

pause

请教,我该如何修改,在修改xml文件后不多出最后一行。
...全文
158 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧