Read XML file with windows batch

后端 未结 4 598
北荒
北荒 2021-01-23 08:09

I\'m trying to read an xml file and read STRING \"50\" between the build tags from a XML file. I tried it but I\'m not getting any output.

The XML file..



        
4条回答
  •  鱼传尺愫
    2021-01-23 08:33

    ...I'm sure you're aware that parsing XML with batch might not be the easiest/smartest thing to do. Tools like xmlstarlet and xidel are better suited for this:

    xidel -q file.xml -e //build
    

    ...to save the buildnumber in a variable X and output it:

    @echo off
    for /f "delims=" %%a in ('xidel -q --output-format cmd file.xml -e "x:=//build"') do %%a
    echo Build version = %x%
    

    ...even nicer would be if BeniBela (xidel coder) could program something like the following to directly set the environment variables and not generate a set command as ouput. That would be very powerful (and short). Beni? You're up for this? :-)

    xidel -q -cmd file.xml -e x:=//build
    

提交回复
热议问题