What Is It?

If you need to read XML documents and already know C's scanf, you can quickly use Ali. It's scanf like approach is much easier than using SAX or DOM. A tutorial, complete reference documentation, and code examples in the download are all provided. Ali is pronounced like "Alley".

Latest Version

Ali 1.2 was released 5/1/2016.

Ali Example

Pretend you want to input address book data like:

<person id="1000">
    <name>Roger Flores</name>

You could write C code using Ali like this:

    /* Open the xml document, read it, and close it. */
    rootN = ali_open(&doc, "person.xml", ALI_OPTION_NONE, &my_data);
    if (doc != NULL)
        personN = ali_in(doc, rootN, "^e", 0, "person");
        if (personN != 0)
            person = a_new_person();
            ali_in(doc, personN, "^a%d", 0, "id", &person->id);
            ali_in(doc, personN, "^e%s", 0, "name", &person->name);
            ali_in(doc, personN, "^e%u", 0, "zipcode", &person->zipcode);
            ali_in(doc, personN, "^e%s", 0, "state", &person->state);

Notice the following points:
  1. The syntax is simple and concise. Reading data from an XML element into a variable can be done in one line.

  2. Familar scanf like reading is used to make handling formats easy. The "^e%s" reads an element and stores it in a string. A "^a%d" reads an attribute as a decimal number.

  3. The code follows the document, and is all together in one function. That keeps it easy to write.

A tutorial is available to quickly get started. By the end of the tutorial you will know enough to parse complicated XML, like RSS feeds using just your app's C code and Ali. The tutorial includes working code to read Slashdot's RSS feed! Also, a complete reference list of commands to read XML is in the documentation included with the distribution.

Ali is a about 15 KB compiled and can be easily added to your program. It is great for small or embedded projects.

Ali is LGPL licensed so you can simply link the library into your projects.


Alo is a matching project to write XML. Together they allow apps to save and load data files and preferences.

These have proven useful.

XML is developed by the World Wide Web Consortium. It has the defining document for XML as well as several other technologies.
This is a collection of schemas for structuring data. Use of them may make your data much more widely used.
JEdit is a nice editor for XML. It is a free Java editor with numerous extensions.

Send comments to Roger Flores Logo