Russian? »

yXML

yXML (yocto XML) is a pretty fast and small C library for reading and writing plain XML data. It doesn't need any additional libraries for building itself, only standard ones. The size of the source does not exceed 300 lines in C and has enough of comments inside. It is very simple in use and modify. The license is very good — modified BSD license a.k.a. the 3-clause BSD license, GPL-compatible.

Speed

The testing was on my laptop with CPU "AMD Turion 64" (2GHz, 3990.15 bogomips) under OS Ubuntu Linux 9.04. I've got the following maximal speed of XML processing (MB is 1024 KB):

  • Reading XML data from a string (speed of function yxml_read): 37-52 MB/sec
  • Converting XML data back to string (speed of yxml_write): 122 MB/sec

When tested under MS Windows XP SP3 on a computer with an Intel Atom N270 CPU (1.6 GHz) the speed was 8 and 67 MB/sec respectively. In both cases, the compiler is GCC.

Example

/* example.c */

#include <stdio.h>
#include <stdlib.h>
#include "yxml.h"

int main()
{
    const char *p;
    int len;
    yxml_t *xml = yxml_read("<data id='mydata'> test <detail index='1' /><detail index='2' /></data>", &p);
    char *str = yxml_write(xml, &len);
    yxml_view(xml);
    printf("%s\n", str);
    yxml_free(xml);
    free(str);
    return 0;
}

/* Make: gcc -x c -O3 yxml.c example.c -o run_example */

Restrictions

yXML does not support all of XML abilities. At the moment, you can only use the most important things here — tags, attributes, comments and plain text content inside tags. Comments are skipped as well as special tags <? .. > and <! .. >. It is enough for storing varied configuration information or data files.

Discussion »
yXML FAQ »
Download » ( the last version is 1.1 )

Valid HTML 4.01 Valid CSS