如何读取批处理XML文件? [英] How to read a XML file in batch?
本文介绍了如何读取批处理XML文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含这样一行一个XML文件:
I have a xml file containing a line like this:
<id>2012-10-19_23-10-04</id>
我想使用批处理文件来读取XML文件,获取内容,并将其分配给一个变量。
I want to use the batch file to read the xml file, get the content and assign it to a variable.
我知道批次可能不是这样做的preferred的方式,但我只被允许在这种情况下使用批处理。
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!
编辑:
我有这样一个模板:
setlocal disableDelayedExpansion
set input="xml.xml"
set output="result.txt"
REM Some Code here:
REM END
我认为XML斯塔利特可能开始如何做到这一点使用xmlstarlet一个很好的工具,任何想法?
推荐答案
没关系,通过使用XML斯塔利特解决这个问题:
Never mind, solve this by using 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明星: http://xmlstar.sourceforge.net/
For you reference, download XML starlet from here: http://xmlstar.sourceforge.net/
这篇关于如何读取批处理XML文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文