Click to See Complete Forum and Search --> : Merge XML File


nit
September 23rd, 2002, 11:40 PM
I have 2 XML files with same DTD ,i want to merge both the XML files,through VB

Thanks in advance

Regards
Nit

Ungi
September 23rd, 2002, 11:47 PM
Use the DOM!

The steps should be:


Create DOMDocument of the first XML File.
Create DOMDocument of the second XML File.
Create new DOMDocument

For each Element in the First DOMDocument
add this Element to the new DOMDocument
next Element

For each Element in the Second DOMDocument
add this Element to the new DOMDocument
next Element

Save the new Document


Try to implement this steps. If there special questions post them!

nit
September 24th, 2002, 01:27 AM
Thats fine but what if both files have same record?

Ungi
September 24th, 2002, 01:32 AM
Try this:

Create DOMDocument of the first XML File.
Create DOMDocument of the second XML File.
Create new DOMDocument

'add all elements of the first DOMDocument
For each Element in the First DOMDocument
add this Element to the new DOMDocument
next Element

'add those elements of the second that are not in the first
for each Element in the Second DOMDocument
check if this element in the first DOMDocument by compare with each Element if it

if not found in first DOMDocument
add this element to the new DOMDocument
endif
next Element

save the new DOMDocument


hope this helps...