0

I have a xml file containing a line like this:

<id>2012-10-19_23-10-04</id>

I want to use the batch file to read the xml file, get the content and assign it to a variable.

I know batch is probably not the preferred way to do this, but I am only allowed to use batch in this case.

Any ideas? Thanks in advance!

EDIT:

I have a template like this:

setlocal disableDelayedExpansion

set input="xml.xml"
set output="result.txt"

REM Some Code here:

REM END

I think XML Starlet might be a good tool to start, any ideas how to do this using xmlstarlet?

4

1 回答 1

2

没关系,使用 XML Starlet 解决这个问题:

@echo off
setLocal EnableDelayedExpansion

for /f %%i in ('XML.EXE sel -t -v "/id" C:\xml.xml') do set var=%%i
echo date is %var%

供您参考,从这里下载 XML starlet:http: //xmlstar.sourceforge.net/

于 2012-10-26T19:49:16.007 回答