Forum Discussion

awhawh's avatar
awhawh
Contributor
7 years ago
Solved

aqFile.Compare not matching XML files even though they are the same

Hi,   I've been using the aqFile.Compare method to compare the contents of two XML files (one that gets generated by Crystal reports) and another pre-validated XML report.   I've had instances wh...
  • HarnekSandhu's avatar
    HarnekSandhu
    7 years ago

    The files are the same and also do differ - the context is important.

     

    If you compare byte by byte, i.e. a binary compare, they are one byte different in size. There is an additional non visible character after the "NINO" string:

     

    </Text>
    <Text Name="Text20"><TextValue>NINO
    </TextValue>

     

    This is 0x0D and the other is 0x0D 0x0A - very common issue with different line endings. The size differs and that is enough to fail a binary compare. See image

     

    Contextually, if you look at them as XML files and look at the content in that context, the relevant content is equal.

    I suspect you need to do a line by line comparison but even that is not a true XML context sensitive comparison as different formatting may throw the compariosn off.. A proper comparison would be to parse the XML file with an appropriate driver or library and compare in the true context.

     

    Hope that helps.

     

    Harnek