Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. IT & Infrastructure
  4. Comparing two XML Documents(Files)

Comparing two XML Documents(Files)

Scheduled Pinned Locked Moved IT & Infrastructure
questiontestingbeta-testingxmlhelp
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Firoz
    wrote on last edited by
    #1

    Hi, I have two XML files (In-Use xml and Backup xml). one is a backup copy of the other. In case of curruption to the In-Use xml, I want to restore from the Backup xml. In my case, curruption is a condition where a node or child node is missing. The data may be different.

    So,I want to compare the two XML files to check
    whether they have the same structure...(ie: the Nodes and ChildNodes)

    How can I compare two xml files ?? Currently I am doing it in a very lengthy way... Trying to access each element and testing for error in accessing... Can someone suggest me an easy way of doing this ??? Thanks Firoz

    N M 2 Replies Last reply
    0
    • F Firoz

      Hi, I have two XML files (In-Use xml and Backup xml). one is a backup copy of the other. In case of curruption to the In-Use xml, I want to restore from the Backup xml. In my case, curruption is a condition where a node or child node is missing. The data may be different.

      So,I want to compare the two XML files to check
      whether they have the same structure...(ie: the Nodes and ChildNodes)

      How can I compare two xml files ?? Currently I am doing it in a very lengthy way... Trying to access each element and testing for error in accessing... Can someone suggest me an easy way of doing this ??? Thanks Firoz

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      You might be able validate the documents against a schema. That should catch the corruption. Otherwise I believe the only way is to examine each element.

      1 Reply Last reply
      0
      • F Firoz

        Hi, I have two XML files (In-Use xml and Backup xml). one is a backup copy of the other. In case of curruption to the In-Use xml, I want to restore from the Backup xml. In my case, curruption is a condition where a node or child node is missing. The data may be different.

        So,I want to compare the two XML files to check
        whether they have the same structure...(ie: the Nodes and ChildNodes)

        How can I compare two xml files ?? Currently I am doing it in a very lengthy way... Trying to access each element and testing for error in accessing... Can someone suggest me an easy way of doing this ??? Thanks Firoz

        M Offline
        M Offline
        markkuk
        wrote on last edited by
        #3

        The XML Signature WG of W3C deals with this problem. If you convert both files to "canonical XML" form, you should be able to find the differences with a simple string comparision.

        R 1 Reply Last reply
        0
        • M markkuk

          The XML Signature WG of W3C deals with this problem. If you convert both files to "canonical XML" form, you should be able to find the differences with a simple string comparision.

          R Offline
          R Offline
          Rassman
          wrote on last edited by
          #4

          Thats a good idea. The schema is all very well but not every structure/field is used in every xml which belongs to its family. So, although I am able to check a 'good' xml against the schema, I was struggling with auto-repair on corrupted ones. Your idea helps in that. We do it for the joy of seeing the users struggle.

          J 1 Reply Last reply
          0
          • R Rassman

            Thats a good idea. The schema is all very well but not every structure/field is used in every xml which belongs to its family. So, although I am able to check a 'good' xml against the schema, I was struggling with auto-repair on corrupted ones. Your idea helps in that. We do it for the joy of seeing the users struggle.

            J Offline
            J Offline
            jkgh
            wrote on last edited by
            #5

            I'd augment that with a Hash table and markers then, so you can find out whcih nodes dont exist anymore. Al When a man goes on a date he wonders if he is going to get lucky. A woman already knows - Frederick Ryder

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups