【发布时间】:2019-02-10 13:20:58
【问题描述】:
我有一个看起来像这样的 xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customer>
<role>probe</role>
<ipconfig>yes</ipconfig>
<hostname>test</hostname>
<ip>192.168.2.123</ip>
<gateway>192.168.2.1</gateway>
<subnet>255.255.254.0</subnet>
</customer>
我在 CentOS7 下有脚本来获取值:
role="$(xmllint --xpath "string(//role)" "${xml_path}")"
这很好用。
现在我必须在 CentOS 6 环境下使用相同的。没有 --xpath 支持,我无法安装它。
实现相同目标的最简单和最简单的方法是什么?
【问题讨论】: