我有一个xml:
<block name="http-www.example.com">
<mapentry tag="AB12">bottlecap</mapentry>
<mapentry tag="CD45">description goes here</mapentry>
<mapentry tag="GH23">12345</mapentry>
<mapentry tag="JK89">54321</mapentry>
</block>我想根据这个值找到“标签”。
所以我想搜索“瓶装水”并让它返回"AB12“
在我看到的所有示例中,人们搜索属性以获得结果,但在这种类型的xml中,这是不可能的,因为节点和属性是不明确的
我一直试图使用-i,但这似乎只适用于节点或属性,而不适用于值。
xmlstarlet sel -t -i //bottlecap -v "//mapentry[@tag]" "mytest.xml"有什么方法可以搜索这个值吗?
发布于 2014-07-15 13:25:06
也许这就是你想要的?
xmlstarlet sel -t -v "//mapentry[. = 'bottlecap']/@tag" "mytest.xml"https://stackoverflow.com/questions/24759220
复制相似问题