Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing XML files

Status
Not open for further replies.

yvsatyaprasad

Programmer
Aug 10, 2004
4
US
Can someone please help me in comparing two XML files.i need to compare two XML files and output the discrepancies.Does someone have any code.
 
Master .... I am here to server your demands ...


Would you prefer String based, or DOM based, or SAX based comparison ?

How do you define "compare" ? Node names, node content, or purely byte data level ?


--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
while you're at it sedj, can i get that in a nice color coded gui with pretty lines to show the differences?

-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
You could use Visual Source Safe if you want a nice color coded gui with pretty lines to show the differences!

Follow these steps:
1. Load one of the xml files into Visual Source Safe

2. Check the file back out to your dekstop

3. Delete the file you just checked out

4. Copy the other xml file to your desktop and rename it so it has the same name as the file you just deleted in step 3

5. Do a "check in" in Source Safe, this will cause the second file to replace the first one.

6. Choose Show History, click OK, select both versions of the file and then click the button labeled "Diff"

7. Enjoy your happy colered GUI
 
sedj-
I am looking for DOM based, or SAX based comparison.

What i meant by compare is ,comparing nodes and node content and displaying the difference i.e <Node><Child>, <Node><Child><Child>
 
You probably want to use DOM, as using SAX may give you problems to synchonously access two xml files.

I think you should read the DOM API tutorial, work out how to rip through a DOM, and then you will be away :
--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top