XML示例:
<?xml version="1.0" encoding="UTF-8"?>
<profile>
<section name="Vision">
<key name="Name" value="BBBB"/>
<key name="Name_Remark" value="GGGG"/>
<key name="Position" value="30"/>
</section>
</profile>我如何才能得到价值的xmlstarlet,其中的名字是“位置”。现在是30岁。
谢谢。
发布于 2017-05-26 20:45:57
你可以用这个命令行..。
xmlstarlet sel -t -v "/profile/section/key[@name='Position']/@value" -n input.xmlsel命令告诉xmlstarlet选择。
-t选项告诉xmlstarlet,-t后面的选项用于模板。
-v告诉xmlstarlet打印XPath表达式的值。
-n告诉xmlstarlet打印一条新行。(并非完全有必要)
所有这些都可以通过从命令行运行xmlstarlet sel --help来找到。
https://stackoverflow.com/questions/44209350
复制相似问题