<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>
我正在尝试找到物品的属性2,其中识别者的值为1234.我可以选择数据:
$xmlstarlet sel -t -c "/DATA/TABLES/ITEM/identifyer [@V=1234]" test.xml <identifyer V="1234"/>
两种类型的输出将是可取的:
$xmlstarlet <some magic> <identifyer V="1234"></identifyer> <property1 V="abcde"></property1> <Property2 V="qwerty"></property2>
和:
$xmlstarlet <some magic> qwerty