Combining multiple xml documents into one large one with a batch file

后端 未结 6 555
夕颜
夕颜 2020-12-18 09:55

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 firs

6条回答
  •  悲哀的现实
    2020-12-18 10:45

    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 ("").

    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 ^ > %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
    

提交回复
热议问题