Re: Merge two XML data with libexpat?
Shawn Walker <[email protected]> Thu, 08 Nov 2007 17:25:51 -0600
| Newsgroups | gmane.text.xml.expat.general |
|---|---|
| Message-ID | <[email protected]> |
Nick MacDonald wrote: > There is no such thing as a correct way to merge two arbitrary XML > files. You're talking about combining to completely self-sufficient > entities into a third entity with some sort of intelligence. That's > kinda like saying is there a tool to merge two books or two > spreadsheets or two companies. (The tool is the human brain.) Each > file should, in theory, have a schema, and the correct way to merge > them would probably involve output according to a third schema. (Not > that eXpat is a schema validating parser, but that's not really the > point here.) That's why it's quite difficult for me to try to even come up with something to merge in two XML data since I have no idea what some other application would put in the XML file. > > There may well be existing tools that can do this... but its likely > any tool would have to understand the content/context of each file to > know how to merge it. Its not something I have ever heard of > before... to me it sounds like you need a custom written tool. (Of > course, if you haven't yet done a search on SourceForge on merge and > XML then who knows what you might find.) I have been looking on SourceForge and google, but either somebody has some information on using Microsoft APIs using VisualBasic or some DOM object. But, I need it in C or C++. > > eXpat may not even be your best choice... it sounds like you would > need to read the entirety of one document into memory (which is more > of a DOM parser model than a SAX parser model) and then add/insert the > contents of the second one into the correct places and then write out > a brand new document. > > In any case, hopefully your schema's are both very > simple/straightforward and you can easily craft a special tool to > solve your problem. It's rather simple, but I would have no idea if somebody else would decide to throw in a complex schema. > > Good luck, > Nick > > > On 11/8/07, Shawn Walker <[email protected]> wrote: >> [email protected] wrote: >>> On 8 Nov, Shawn Walker wrote: >>>> Has anybody used libexpat to merge two XML data into one? Or does >>>> somebody know of a good library to do that? >>> "[T]o merge two XML data" mean exactly what? >> What I mean is that I have two XML files. I created a new XML file >> based on some data but I need to merge in the old XML file to merge in >> data that I don't know about that another application had put in the XML >> file.