You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Lars <la...@hotmail.com> on 2017/07/07 12:04:38 UTC

Compare xml files

Hello,


Does Xerces-C++ 3.1.4 contain a method to compare two xml files? Reviewing the API references I could not find any such functionality.


This is needed during unit testing.


kind regards, LarsA


SV: Compare xml files

Posted by Lars <la...@hotmail.com>.
Hei Bodi,


Thanks for the link, will take a look at that.


Using memcpy is to strict. We want to know if the two xml files are equal but want to ignore any whitespace differences or different ordering of attributes or different namespace prefix etc.


kind regards, LarsA


________________________________
Fra: Bodi Ngwala <bo...@ecrebo.com>
Sendt: 7. juli 2017 14:20
Til: c-users@xerces.apache.org
Emne: Re: Compare xml files

Hi LarsA

Not sure if Xerces has that but check here :
https://stackoverflow.com/questions/5169313/need-to-find-the-difference-between-two-xml-files-in-c

[https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon@2.png?v=73d79a89bded]<https://stackoverflow.com/questions/5169313/need-to-find-the-difference-between-two-xml-files-in-c>

Need to find the difference between two XML files in C++ ...<https://stackoverflow.com/questions/5169313/need-to-find-the-difference-between-two-xml-files-in-c>
stackoverflow.com
Is there any library for this, or does anyone have anything done in Xerces, or any link on how to do this, or any API or any way to do this in Xerces?



(or check Xerces c++ samples which ship in the API zip - maybe one of them
does this or similar?)

Or if you just want your unit test to inform whether 2 files are identical
then i would just use memcmp( ):
http://en.cppreference.com/w/cpp/string/byte/memcmp

std::memcmp - cppreference.com<http://en.cppreference.com/w/cpp/string/byte/memcmp>
en.cppreference.com
Return value. Negative value if the first differing byte (reinterpreted as unsigned char) in lhs is less than the corresponding byte in rhs. 0 if all count bytes of ...



(Check file sizes, if different then end-of-test, if not different sizes,
then read them in separate memory buffers and compare using std::memcmp( ),
if it returns 0, they're identical, if not 0 then they're different)

All the best,
BN

On 7 July 2017 at 13:04, Lars <la...@hotmail.com> wrote:

> Hello,
>
>
> Does Xerces-C++ 3.1.4 contain a method to compare two xml files? Reviewing
> the API references I could not find any such functionality.
>
>
> This is needed during unit testing.
>
>
> kind regards, LarsA
>
>

Re: Compare xml files

Posted by Bodi Ngwala <bo...@ecrebo.com>.
Hi LarsA

Not sure if Xerces has that but check here :
https://stackoverflow.com/questions/5169313/need-to-find-the-difference-between-two-xml-files-in-c
(or check Xerces c++ samples which ship in the API zip - maybe one of them
does this or similar?)

Or if you just want your unit test to inform whether 2 files are identical
then i would just use memcmp( ):
http://en.cppreference.com/w/cpp/string/byte/memcmp
(Check file sizes, if different then end-of-test, if not different sizes,
then read them in separate memory buffers and compare using std::memcmp( ),
if it returns 0, they're identical, if not 0 then they're different)

All the best,
BN

On 7 July 2017 at 13:04, Lars <la...@hotmail.com> wrote:

> Hello,
>
>
> Does Xerces-C++ 3.1.4 contain a method to compare two xml files? Reviewing
> the API references I could not find any such functionality.
>
>
> This is needed during unit testing.
>
>
> kind regards, LarsA
>
>