tags:

views:

299

answers:

5
+3  Q: 

XMLUnit for C++

Hi,

Anyone knows if there exists something like XMLUnit for C++. I'm looking for an easy way to check nodes, values, etc in a XML output. We are using google test in Visual Studio but I suppose any library that makes the work easier will be enough...

I'm using Xerces as a XML parser but XMLUnit (http://xmlunit.sourceforge.net/) has some features wrapped over the XML parser that are very useful for unit testing. For example, asserts using XPath expressions, functions to compare two "similar" XMLs, etc.

Thanks

Jordi

A: 

When you say "checks"... What do you mean? I have my own STL Template class for dealing with XML that works pretty damn good, and it's very tight, very efficient. Allows me to read nodes, check children, get the text of the nodes, along with all the properties... And it checks that the XML is valid, during runtime, on XML Open, etc.

Are you looking for an XML Lib that will compare two XML files to see if they truly equal each other, even if the tags ARE formatted a little differently?

LarryF
With "check" I meant everything XMLUnit (http://xmlunit.sourceforge.net/) does. Of course I need the things the XML Parsers do but I'm looking for an integration with unit testing (for example gtest). For example, one thing could be what you said: comparing two XMLs that are "a bit" different.
Yea.. That can be a tall order. But I am working on another project that is used for comparing two 'string' to see how similar they are. With my XML class, it COULD read two files, and compare two nodes, and give you an idea of how closely 'related' they are... (The text, no the tags, but..)
LarryF
+1  A: 

You can use tinyxml package here: tinyxml

I'm working with it and it's quite friendly and bug free.

It's an xml handling. I guess it wasn't designed for unit testing, but you can use it to check/test your xml files. It as expected loads the xml into a DOM object and supplies a nice API to run on the nodes.

Gal

Gal Goldman
A: 

Xerces at http://xerces.apache.org/xerces-c/i pretty full featured, has a C++ interface and produces good error messages, which several other XML parsers don't do so well. Having said that, it's pretty big & I've wound up using my own wrapper round the C parser Expat.

anon
A: 

I'm currently using libxml++ for a personal project of mine.

MighMoS
+1  A: 

Thanks to everyone. As you can get from the answers, it seems there is no good XMLUnit solution for C++. I suppose this is also due to not having a "standard" unit testing library. I used Unittest++ and now I'm migrating to google test but I suppose cppunit etc are used too. I think I will have to create some "testing" wrappers functions for XML (using a XML parser) based on what XMLUnit has...