Xml comparison using any parsers in java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ramganes
    New Member
    • Mar 2008
    • 2

    Xml comparison using any parsers in java

    Here is one xml file name file1.xml

    <?xml version="1.0" encoding="UTF-8" standalone="yes "?>
    <ns1:samns ns1:id="1239" xmlns:ns1="http ://blogs.sun.com/teera/ns/samns">
    <ns1:firstName> arvind</ns1:firstName>
    <ns1:lastName>k rishna</ns1:lastName>
    <ns1:address>ch ennai</ns1:address>
    </ns1:samns>

    Here is the another xml file called file2.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <customer>
    <firstName>sach in</firstName>
    <lastName>tendu lkar</lastName>
    </customer>

    I want to compare these two file1.xml and file2.xml files find out the matching tags in both files.
    like <firstName></firstName><last Name></lastName>
    get the values from file1.xml and put it in file2.xml tags

    sample output:
    result3.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <customer>
    <firstName>arav ind</firstName>
    <lastName>krish na</lastName>
    </customer>

    what shout i do for this.. can anyone help me out with this
  • ramganes
    New Member
    • Mar 2008
    • 2

    #2
    am waiting for long time is there anybody to reply?

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by ramganes
      am waiting for long time is there anybody to reply?
      What have you tried so far? Do you know how to read/parse XML files in Java? JAXP is a good starting point for the googling.

      Comment

      • pronerd
        Recognized Expert Contributor
        • Nov 2006
        • 392

        #4
        Originally posted by ramganes
        I want to compare these two file1.xml and file2.xml files find out the matching tags in both files.
        I do not think XSL will let you compare files, so you will probably want to google for examples using the DOM and or SAX parsers to create the code to do this.

        Comment

        Working...