xml2c - convert an XML file into C struct/string declarations

Fetch the software.

xml2c reads in an XML file and produces equivalent C source code, suitable for #including in your program. The C version is probably easier deal with in your code. You don't have to read and parse the XML file and then look for the nodes you want; instead you just loop through a bunch of structs. Or maybe you just don't want to distribute extra files with your app, and would rather build them into the executable.

Example input:

<?xml version="1.0" encoding="utf-8" ?>
  <item id="1" value="17">this item</item>
  <item id="2" value="23">that item</item>
  <item id="3" value="42">the other item</item>

Example output:

% xml2c sample.xml
struct _item {
    char* id;
    char* value;
    char* TEXT;
struct _list {
    struct _item item[3];
    int N_item;
static struct _list list = {
        { {
        "this item",
        }, {
        "that item",
        }, {
        "the other item",
        } },

See the manual entry for more details.

ACME Labs / Software / xml2c