【发布时间】:2022-01-05 08:38:05
【问题描述】:
输入 XML 看起来像几个块:
<Parties>
<Party compid="CUST1" side="1">
<Connections>
<SocketConnection listenport="9029" />
</Connections>
</Party>
</Parties>
我的目标是为每个客户提取他的特定参数,例如: compid;监听端口
现在我可以让所有客户使用
xmlstarlet fo -D config.xml | xmlstarlet select -T -t -m '//Parties/Party' -v '@compid' -nl
下一步将是每个客户获取他的监听端口的循环,但是
xmlstarlet fo -D config.xml | xmlstarlet select -T -t -m '//Parties/Party[@compid="CUST1"]' -v 'Connections/SocketConnection/@listenport'
或任何其他尝试都不会返回任何内容。
我在使用[@value=string] 进行过滤时是否遗漏了什么?
提前致谢!
【问题讨论】:
标签: xml bash xpath xmlstarlet