cancel
Showing results for 
Search instead for 
Did you mean: 

Need help in CPI Groovy script to return difference in XML documents

0 Kudos

Hi ,

I want to compare the two xml files and return the difference in those files.

I am storing the two xml's in the datastore and getting the two xml's using datastore get operation then storing it in a properties.

Those properties i am calling in the script . Now I am able to get the two xml files in the groovy. Now I need to compare those two xml files in groovy.

Need help in comparison of those two files in groovy. Can anyone share the code for returning the differences.

Thank you..

Regards,

Chandrasekhar

MortenWittrock
Active Contributor
0 Kudos

Hi Chandrasekhar

You have another open question about the same thing. Also, it's a very broad question. I think you'll fare better if you go into some detail about what you are actually trying to achieve here. I'm guessing those differences represent something that's meaningful in some context. Like, the first document contains employees at one point in time, and the other contains employees at another point in time. Maybe you need to find out who was hired and who left between those two points in time? I don't know, because you didn't tell us 🙂

A specific problem here is probably much easier to solve than the very general problem you are describing. So please add the relevant context and show some sample XML. No sensitive information, of course, and no huge documents please. Also, use the CODE button to embed the XML in the question (not a comment), to make it a lot more readable.

Regards,

Morten

0 Kudos

Hi 7a519509aed84a2c9e6f627841825b5a , Thank you for the response.

Due to security reasons I am not sharing the actual xml file. Below is the sample data for better understandings.

XML1:

<root>
<rdm>
<Model> aa</model>
</rdm>
<rdm>
<Model> bb </Model>
</rdm>
</root>

XML2:

<root>
<rdm>
<Model> aa</model>
</rdm>
<rdm>
<Model> bb </Model>
</rdm>
<rdm>
<Model>cc</Model>
</rdm>
</root>

output should be achieved as below:

<root>
<rdm>
<Model>cc</Model>
</rdm>
</root>

Need Groovy script to achieve the above output.

Regards,

ChandraSekhar

AmanVarshney
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi chandrasekharkoduru450 ,

Were you able to find a solution to this?
I am currently struggling with same kind of issue finding difference between 2 similar schema xmls

Best Regards,

Aman Varshney

Accepted Solutions (0)

Answers (0)