Search and Compare between 2 Files and writing the results into another file.
Posted on 2008-10-02
I have 2 files. Both of these files have XML formats.
First File has Single Line XML Requests and second file has single line XML OutPuts.
Every Request Line has an ID associated to it and the corresponding response will have the same ID in it.
Now the problem is to separate those request lines from the Request File which has no corresponding success response in the Response File.
There fields in the XML which have ID And Status Information in the same line.
<Id>123</ID> ...... <Status>Success</Status>
what this means is, For every Line in Request File, There will be a ID Filed, whose value will uniquely identify that request. This Id needs to be searched in the Response File, If I find that ID, in the same Line I should Find the <Status>Success</Status>.
If I do not find the Id at all in the Response File or After finding the Id, the <Status>Success</Status> is not found in the same line, then the Corresponding Line from the REQUEST FILE need to be copied into a FailedRequestsFile.
So I hope the description I gave explains that this is all about filtering the requests which failed to retuning a response at all or returned a Fail response. so that we can reprocess them.