Let me put the scenario: If the 'Student' node has same child elements then merge the 'Student' node. In this case if the 'Name' node is found in other 'Student' nodes with same value then those 2 'Student' nodes need to be merged with unique elements. In this case the 'Name' node being identical comes 1 time and the 'Address' node coming 2 times. Also the input xml can have different set of child nodes and can have different names every time. Below is Input xmlLet me put the scenario: If the 'Student' node