Re: Merge two XML data with libexpat?
"Nick MacDonald" <[email protected]> Thu, 8 Nov 2007 18:09:55 -0500
| Newsgroups | gmane.text.xml.expat.general |
|---|---|
| Message-ID | <[email protected]> |
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.) 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.) 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. 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.