Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 用批处理文件替换xml节点属性_Batch File - Fatal编程技术网

Batch file 用批处理文件替换xml节点属性

Batch file 用批处理文件替换xml节点属性,batch-file,Batch File,我必须使用批处理文件替换XML节点属性值,XSLT和其他方法都不是选项 要查找的节点属性: addkey=“RemEnabled”value=“true”/> 替换为: addkey=“RemEnabled”value=“false”/> 我一直在为有引用的事实而挣扎,到目前为止,我得到的是: echo off setlocal enabledelayedexpansion set txtfile=x.config set newfile=xnew.config if exist "%newfi

我必须使用批处理文件替换XML节点属性值,XSLT和其他方法都不是选项

要查找的节点属性:
addkey=“RemEnabled”value=“true”/>

替换为:
addkey=“RemEnabled”value=“false”/>

我一直在为有引用的事实而挣扎,到目前为止,我得到的是:

echo off
setlocal enabledelayedexpansion
set txtfile=x.config
set newfile=xnew.config
if exist "%newfile%" del /f /q "%newfile%"
for /f "tokens=*" %%a in (%txtfile%) do (
set newline=%%a 
set newline=!newline:^"RemEnabled^" value=^"true^"=^"RemEnabled^" value=^"false^"!
echo !newline! >> %newfile%
)

非常感谢的任何帮助

这将使用一个名为repl.bat的帮助程序批处理文件,该文件来自-

type file.xml|repl "(.*add key=\x22RemEnabled\x22 value=\x22)true(\x22 \/>.*)" "$1false$2" >file2.xml