XML -> C parser generator
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 progr开发者_C百科am, 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.
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
Given your XML files have common pattern, you can use Bison+Flex or simply ANTLR (C runtime) to construct grammar and extract the values from the XML files to variables. Those will produce parsers in pure C so you have nothing to worry about.
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/
精彩评论