views:

43

answers:

2

Hello! 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!

A: 

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/

Travis
A: 

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

James