简体   繁体   中英

Merging XML files

How do I merge multiple XML files, without having redundant data? I have a project using OpenStreetMap, and the data dumps are in XML format. But becuase I plan to divide my target area in the map, then some nodes(points in the map) will be repeated in the XML files. I want to merge all that XML files, and prevent redundant data in the resulting merged file. Thanks in advance!

I would read each XML file (be it 2, 3,...,N files) into a map. Each time I read a new entry, I would check to see if it's in the map, if it is, make some determination as to which is the entry you want (or merge possibly merge them).

Then when you're done parsing each XML file, dump the map to a "merged" xml file.

These XML parsers may be of help.

http://www.grinninglizard.com/tinyxml/ http://www.xmlsoft.org/

Do you want to merge these XML files programatically, or do you want to merge them offline using some merge tool? If it's the latter, Project: Merge might be able to help you. It can merge two distinct XML files at a time, and can be run from the command line, so you could batch up all the files you want to merge and then just resolve conflicts as they appear. (Project: Merge will run silently from the command line if there are no conflicts.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM