views:

62

answers:

2

I have a c program, that gets its settings from an XML file. Currently I'm using Xerces to traverse the data, but it's getting quite tedious to map each XML-value to a variable.

The same XML is also read by a Java program, which is much more convenient due to JAXB creating all the necessary classes and such in Java. I'm looking for something similar that can create a "structure of structs" or some such. It's important that I get c structs, and not c++ classes, because this code will run on GPUs.

I found "XML Booster", and am currently reading it docs. Do you know of other options? Needs to be usable in linux.

+1  A: 

i use the libxml library. You still have to traverse the XML, but you get a linked list with elements, attribues, nodes and children-nodes, which you can follow.

link: http://xmlsoft.org/index.html

Peter Miehle
Thanks, but is there a large difference between libxml and xerces? I already get a list of nodes and that I for-loop over. I might just missunderstand something basic about how libxml works, but I took a look at it an concluded it wouldn't improve the situation.
Claes
i do not know Xerces. I was "Answering" your "map each XML-value to a variable" part.
Peter Miehle
I appreciate that you answered my question, but "map each XML-value to a variable" is the problem I'm trying to get away from, not re-create :)
Claes
A: 

If you have an xml schema, check out xsd codesynthesis. It generates nice c++ objects for your xsd and you don't need to deal with xerces directly: http://www.codesynthesis.com/products/xsd/

Fabian
That's a great option, but I should have expressed myself more clearly in the question. Classes are not an option, as the bulk of the application runs on GPUs. I need pure C code. I've updated my question to reflect this better.
Claes