【发布时间】:2021-05-27 23:43:17
【问题描述】:
有这样一个 XML 文件。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model-response-list xmlns="http://www.ca.com/spectrum/restful/schema/response" total-models="922" throttle="922" error="EndOfResults">
<model-responses>
<model mh="0x1058905">
<attribute id="0x1006e">prod-vpn-gw-v01.e-x.com</attribute>
</model>
<model mh="0x1058907">
<attribute id="0x1006e">prod-storage-san-z01-ssh.e-x.com</attribute>
</model>
<model mh="0x1058900">
<attribute id="0x1006e">test-vpn-gw-v01</attribute>
</model>
</model-responses>
</model-response-list>
我需要打印一份清单:
0x1058905 prod-vpn-gw-v01.e-x.com
0x1058907 prod-storage-san-z01-ssh.e-x.com
0x1058900 测试-vpn-gw-v01
我试过了:
xmllint --xpath "//[local-name()='model']/[local-name()='attribute']/text()" devices.xml p>
但它只是为了名称,真的不知道如何将它与 an 一起使用以获得 0x... mh 值。
有人可以帮忙吗? 谢谢。
【问题讨论】: