Comparing two XML Documents(Files)
-
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
-
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
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.
-
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
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.
-
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.
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.
-
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.