从命令行合并多个 XML 文件 [英] Merge multiple XML files from command line
本文介绍了从命令行合并多个 XML 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有几个 xml 文件.它们都具有相同的结构,但由于文件大小而被拆分.所以,假设我有 A.xml
、B.xml
、C.xml
和 D.xml
和想要使用命令行工具将它们组合/合并到 combined.xml
.
I have several xml files. They all have the same structure, but were splitted due to file size. So, let's say I have A.xml
, B.xml
, C.xml
and D.xml
and want to combine/merge them to combined.xml
, using a command line tool.
A.xml
<products>
<product id="1234"></product>
...
</products>
B.xml
<products>
<product id="5678"></product>
...
</products>
等
推荐答案
xml_grep
http://search.cpan.org/dist/XML-树枝/工具/xml_grep/xml_grep
xml_grep --pretty_print indented --wrap products --descr '' --cond产品"*.xml > 组合.xml
xml_grep --pretty_print indented --wrap products --descr '' --cond "product" *.xml > combined.xml
- --wrap :用给定的标签包含/包装 xml 结果.(此处:
products
) - --cond : grep 的 xml 子树(这里:
product
)
这篇关于从命令行合并多个 XML 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文