首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >xmlstarlet -搜索属性

xmlstarlet -搜索属性
EN

Stack Overflow用户
提问于 2012-01-31 19:06:50
回答 1查看 1.2K关注 0票数 2

以下面的xml为例:

代码语言:javascript
复制
<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”

你建议我使用的其他命令行脚本?谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-01-31 19:55:43

可能是这样的:

代码语言:javascript
复制
//epp:phrase[@id="Plugin/Screen/BatchEdit:remove_title"]/text()

编辑:

代码语言:javascript
复制
$ xmlstarlet sel -t -v '//epp:phrase[@id="Plugin/Screen/BatchEdit:remove_title"]/text()' x.xml
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9078457

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档