相关疑难解决方法(0)

xmlstarlet选择值

这是xml-data:

<DATA VERSION="1.0">
  <TABLES>
    <ITEM>
      <identifyer V="1234"></identifyer>
      <property1 V="abcde"></property1>
      <Property2 V="qwerty"></property2>
    </ITEM>
    <ITEM>
      <identifyer V="5678"></identifyer>
      <Property1 V="zyxwv"></property1>
      <Property2 V="dvorak"></property2>
    </ITEM>
  </TABLES>
</DATA>
Run Code Online (Sandbox Code Playgroud)

我试图找到有价值property2的项目.我可以选择数据:identifyer1234

$ xmlstarlet sel -t -c "/DATA/TABLES/ITEM/identifyer [@V=1234]" test.xml 
<identifyer V="1234"/>
Run Code Online (Sandbox Code Playgroud)

需要两种类型的输出:

$ xmlstarlet <some magic>
<identifyer V="1234"></identifyer>
<property1 V="abcde"></property1>
<Property2 V="qwerty"></property2>
Run Code Online (Sandbox Code Playgroud)

和:

$ xmlstarlet <some magic>
qwerty
Run Code Online (Sandbox Code Playgroud)

xml xmlstarlet

16
推荐指数
1
解决办法
3万
查看次数

标签 统计

xml ×1

xmlstarlet ×1