linux - 如何使用 shellscript 解析 XML?

这个问题在这里已经有了答案:
关闭6年前

我想知道使用 shellscript 解析 XML 文件的最佳方法是什么?

  • 应该手工完成吗?
  • 是否存在第三层库?

如果你已经做到了,如果你能告诉我你是怎么做到的

最佳答案

你可以试试xmllint

The xmllint program parses one or more XML files, specified on the command line as xmlfile. It prints various types of output, depending upon the options selected. It is useful for detecting errors both in XML code and in the XML parser itse

它允许您通过 xpath 选择 XML 文档中的元素,使用 --pattern 选项。

在 Mac OS X (Yosemite) 上,默认安装。
在 Ubuntu 上,如果尚未安装,您可以运行 apt-get install libxml2-utils

https://stackoverflow.com/questions/4680143/

相关文章:

linux - 如何从文件中提取单个字节 block ?

python - 在 Python 中重置生成器对象

linux - 如何查找几分钟前访问/创建的文件

python - 在 Python 中转义 HTML 的最简单方法是什么?

python - 为什么 ~True 结果是-2?

linux - 带有单引号和双引号的 bash 别名命令

c++ - Netbeans 7.2 显示 "Unable to resolve identifie

python - 如何使用 Python 的 timeit 为代码段计时以测试性能?

python - SQLAlchemy:打印实际查询

linux - Bash - 如何从给定的文本文件中删除所有空格?