Page 1 of 1

Remove Duplicate Nodes

Posted: Wed Sep 24, 2014 5:50 pm
by Sudeesh
Dear All,

I have an XML file which contains duplicates node for a single ID. I would like to compare 2 particular field values from both these nodes and based on the result, I would like to print only one node in output. Please find the below XML File.

*********************************************
<?xml version="1.0" encoding="utf-8"?>
<File>
-<Data>
-<Summary>
<ID>123456</ID>
<Name>James Bond_Old</Name>
</Summary>
-<Information>
<End_Date>2014-08-31</End_Date>
</Information>
</Data>
-<Data>
-<Summary>
<ID>654321</ID>
<Name>Wolverine</Name>
</Summary>
-<Status>
<Current_Status >Active</Current_Status>
<Begin_Date >2014-09-01</Begin_Date>
</Status>
</Data>
-<Data>
-<Summary>
<ID>123456</ID>
<Name>James Bond_New</Name>
</Summary>
-<Status>
<Current_Status >Active</Current_Status>
<Begin_Date >2014-09-01</Begin_Date>
</Status>
</Data>
</File>

************************************************** ******

In the above sample, there are 2 nodes for the ID "123456". In this case, I need to compare the values of "Information/End_Date" of first Node and "Status/Begin_Date" of 2nd Node. If "Begin_Date" is greater than "End_Date", pass the first Node, else vice versa.

Could you please help me!