[英]Read value Inside tags from xml using Batch Script
Example : In test.xml, I have 示例:在test.xml中,我有
<head>
<file name="input">
<above>
<tag point="x"/>
</above>
<below>
<result first="00"/>
</below>
</file>
<file name="output">
<above>
<tag point="y"/>
</above>
<below>
<result first="11"/>
</below>
</file>
</head>
I should read this XML in batch script where i should get value "11" . 我应该在批处理脚本中读取此XML,在该脚本中我应该获得值“ 11”。 This "11" is found inside tag in tag in .
在的标记中的标记内可以找到“ 11”。
I have to get only the value "11" in the above specified path. 在上面指定的路径中,我只需要获取值“ 11”。
This is an example where in a real scenario there can be different value in place of "11". 这是一个示例,在实际情况下,可以使用不同的值代替“ 11”。
Thanks in advance 提前致谢
FOR /F tokens^=2^ delims^=^" %%A in ('find "result first=" test.xml') do echo:%%A
or in command prompt: 或在命令提示符下:
fOR /F tokens^=2^ delims^=^" %A in ('find "result first=" test.xml') do echo:%A
this will work only if the structure of your file is as this above (specifically the new lines). 仅当文件的结构如上所述(特别是新行)时,此方法才有效。 Better use xml startlet http://xmlstar.sourceforge.net/ .
最好使用xml startlet http://xmlstar.sourceforge.net/ 。 More info about the trick with the for - >
有关for的技巧的更多信息->
http://ss64.org/viewtopic.php?id=1544 http://ss64.org/viewtopic.php?id=1544
http://ss64.org/viewtopic.php?id=1572 http://ss64.org/viewtopic.php?id=1572
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.