批处理文件 - 读取xml文件并返回值

时间:2013-04-04 21:40:41

标签: batch-file

需要能够读取xml文件并返回值:

XML文件:

<?xml version="1.0" encoding="UTF-16"?>
<CONFIGSETTINGS>
    <GENERAL>
        <PROGRAM>App/PROGRAM>
        <CURRENCY>GBP</CURRENCY>
        <VERSION>3</VERSION>
        <RELEASE>0</RELEASE>
        <FULLVERSION>24.0.12.123</FULLVERSION>
    </GENERAL>
    <WEBLINKS>

...............

需要能够提取完整版本号并放在批处理文件中的变量中,即:24.0.12.123

1 个答案:

答案 0 :(得分:4)

试试这个:

@echo off &setlocal
for /f "tokens=2delims=<>    " %%i in ('type file.xml ^|find "FULLVERSION"') do set "version=%%i"
echo(%version%
endlocal