问题描述
我有86 XML文件的目录具有相同的列和格式,我需要合并成一个大的XML文件。我非常缺乏经验与批处理文件,我的第一次尝试是简单地添加一个文件文本到下一使用...
I have a directory of 86 xml files with the same columns and formatting that I need to combine into one large xml file. I am very inexperienced with batch files, and my first attempt was to simply append one file text onto the next using...
FOR %%i IN (directory\*.001) DO type %%i >> directory\combo_file.001
不幸的是,当我尝试在Excel中打开它创建了一个解析错误。我猜想,这是因为许多领域和标签是重复的。有谁知道我如何能够实现这一目标?我只需要在Excel中打开这个文件,所以我将开放给文件转换成CSV,如果这是一个选项。
Unfortunately, this creates a Parse error when i try to open it in excel. I would imagine that this is because many fields and tags are repeated. Does anyone know how I might be able to achieve this? I only need to open this file in excel, so I would be open to converting files to CSV, if that was an option.
任何帮助很多AP preciated,谢谢!
Any help is much appreciated, thanks!
推荐答案
下面是结合了当前目录中的所有XML文件到单个文件CombineXML.bat快速批处理命令。它包装全部用新的根节点的XML文件(<根和GT;)。
Here's a quick batch command that combines all the xml files in the current directory into a single file CombineXML.bat. It wraps all the XML files with a new root node ("<root>").
在你的情况,但是,您可能不希望引入这个新层到XML。
如果你正在做的是查看XML在一个区域(如:在web浏览器),然后这个作品
In your case, however, you may not want to introduce this new layer to the XML.If all you're doing is viewing the XML in a single area (eg: in a web browser) then this works.
--CombineXML.bat--
@echo on
rem ==clean up==
erase %0.xml
rem ==add the root node==
echo ^<root^> > %0.txt
rem ==add all the xml files==
type *.xml >> %0.txt
rem ==close the root node==
echo ^<^/root^> >> %0.txt
rem ==rename to xml==
ren %0.txt %0.xml
这篇关于合并多个XML文档成一个大的一个批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!