You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Anuj Seth <an...@sasi.com> on 2000/07/03 08:15:56 UTC

How to merge two XML documents into one?

Hi,

I have two XML documents (actually, RDF documents) and need to combine
them into one single document.

The following features are required,

Lets assume that the 1st file is called 1.xml and the second is called
2.xml

1. If a particular attribute with different values is present in both
the files, the one in 2.xml should be taken.

2. If 2.xml has an attribute not present in 1.xml it should be added to
the combined document.

I'm very new to Xerces-C and don't know how to go about doing the above.
I did go through the examples and have figured out how to read an XML
document, but couldn't figure out how to combine two documents.

Any help will be greatly appreciated.

Thank you,

With Regards,
Anuj


Re: How to merge two XML documents into one?

Posted by Joe Polastre <jp...@apache.org>.
you will have to do the combining yourself.  my suggestion is to read both
documents into a DOM tree using the DOMParser.  Traverse document 2 and
modify document 1 while traversing #2.  Make multiple passes if you need.
After applying the rules you want from document 2 to document 1, doc 1 will
be your combined doc.  you can then output doc 1 through an XML Serializer.

-Joe Polastre  (jpolast@apache.org)
IBM Cupertino, XML Technology Group


----- Original Message -----
From: "Anuj Seth" <an...@sasi.com>
To: <xe...@xml.apache.org>
Sent: Sunday, July 02, 2000 11:15 PM
Subject: How to merge two XML documents into one?


> Hi,
>
> I have two XML documents (actually, RDF documents) and need to combine
> them into one single document.
>
> The following features are required,
>
> Lets assume that the 1st file is called 1.xml and the second is called
> 2.xml
>
> 1. If a particular attribute with different values is present in both
> the files, the one in 2.xml should be taken.
>
> 2. If 2.xml has an attribute not present in 1.xml it should be added to
> the combined document.
>
> I'm very new to Xerces-C and don't know how to go about doing the above.
> I did go through the examples and have figured out how to read an XML
> document, but couldn't figure out how to combine two documents.
>
> Any help will be greatly appreciated.
>
> Thank you,
>
> With Regards,
> Anuj
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>