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.3.1 was released 1/15/2018.

Download Ali

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 24 KB compiled and can be easily added to your program. It is great for small or embedded projects.

Ali is licensed under the GNU Lesser General Public License, just like the commonly used glibc.

Ali has been compiled and tested on gcc 7.2, clang 4.0 and Microsoft Visual Studio Express 2017 15.5. Valgrind has been used to find and fix memory errors.


Be sure to compile and runs the tests to verify your build. They also make useful, working code examples.

# make test
# ./test


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 or questions to Roger Flores

Download Alo