以下面的xml为例:
<epp:phrases xmlns="http://www.w3.org/1999/xhtml" xmlns:epp="http://eprints.org/ep3/phrase" xmlns:epc="http://eprints.org/ep3/control">
<epp:phrase id="Plugin/Screen/BatchEdit:title">Batch Editing Tool</epp:phrase>
<epp:phrase id="Plugin/Screen/BatchEdit:action:edit">Apply Actions</epp:phrase>
<epp:phrase id="Plugin/Screen/BatchEdit:edit_title">Modify Records</epp:phrase>
<epp:phrase id="Plugin/Screen/BatchEdit:remove_title">Remove all Records</epp:phrase>
<epp:phrase id="Plugin/Screen/BatchEdit:remove_help">Destroy all matching items. Once destroyed the items will be gone forever - this action <b>cannot be undone</b>!</epp:phrase>
<epp:phrase id="Plugin/Screen/BatchEdit:confirm_remove">Are you absolutely sure you want to destroy all these items (this action cannot be undone)?</epp:phrase>
</epp:phrases>如何使用xmlstarlet获取搜索@id属性的内部值?
因此,如果我搜索"Plugin/Screen/BatchEdit:remove_title“,我想要的文本是"Remove all Records”
你建议我使用的其他命令行脚本?谢谢
发布于 2012-01-31 19:55:43
可能是这样的:
//epp:phrase[@id="Plugin/Screen/BatchEdit:remove_title"]/text()编辑:
$ xmlstarlet sel -t -v '//epp:phrase[@id="Plugin/Screen/BatchEdit:remove_title"]/text()' x.xmlhttps://stackoverflow.com/questions/9078457
复制相似问题