?
Solved

Merge two or more XML files into one using XercesC

Posted on 2008-10-16
1
Medium Priority
?
717 Views
Last Modified: 2008-11-06
I am in a situation where I need to merge two or more XML files into a single xml file. The root node of the first XML will remain the root of merged file. The contents of the other files will appear under the root node and will retain the same structure. To achieve this, I first tried to merge 2 files and faced following problems:

1) Created two DOM Documents. Got the root node of the first document (->GetDocumentElement) and tried to append it to the DOMDocumentFragment of the second document.
Eg: DocumentElement.appendChild(DocumentFrag);

Result: Failed because the owner documents are different

2) Tried adoptNode() to solve owner document issue, but this failed since there is no implementation in xerces.

3) Tried to create DOMNodeList and insert one node at a tiem and even this failed.

4) Observed that DOMBuilder::parseWithContext() might be the possible solution but failed to understand the exact usage from the given documentation.

If you have any work-around or solution to the above problems, please come forward and guide me. Any help will be appreciated.
0
Comment
Question by:Cool-Guy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
Cool-Guy earned 0 total points
ID: 22894692
Got this solution from one  of my colleagues. it may be helpful for others facing the same problem

DOMDocument *DOMTree2 = parser2->getDocument();

DOMNode *newNode2 = DOMTree2->getFirstChild();                  
DOMNode *newNode1 = parser1->getDocument()->importNode(newNode2, true);
DOMTree1->getLastChild()->appendChild(newNode);            
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question