我有以下 XML。
<application>
<name>Activity Monitor.app</name>
<path>/Applications/Utilities/Activity Monitor.app</path>
<version>10.8.0< /version></application>
<application>
<name>Adobe Flash Player Install Manager.app</name>
<path>/Applications/Utilities/Adobe Flash Player Install Manager.app</path>
<version>11.3.300.268</version></application>
使用 XMLStarlet,我想得到以下输出:
<package name="Activity Monitor.app">
<attribute name="Path">/Applications/Utilities/Activity Monitor.app</attribute>
<attribute name="Ver">10.8.0</attribute >
<package name="Adobe Flash Player Install Manager.app">
<attribute name="Path">/Applications/Utilities/Adobe Flash Player Install Manager.app</attribute>
<attribute name="Ver">11.3.300.268</attribute>
我试过命令:
xml sel -t -v "computer/software/applications/application/path" -v "computer/software/applications/application/name" -v computer/software/applications/application/version
但这只是列出所有应用程序,然后是所有路径,然后是所有版本。我是 XMLStarlet 新手,所以我将不胜感激任何/所有帮助!谢谢!