XML Parse Library

Project: sourceforge.net/projects/xmlparselib
January 2, 2012

XML-Parse library is a lightweight set of re-usable functions for general purpose parsing, checking, and creating xml files. It can support stream-oriented, SAX or DOM parsing styles, and includes an optional xsd schema validator and graphical schema generator. It supports all valid XML, and includes checking for validity. This library has minimal dependencies, and is totally self-contained. It is written in C and is both speed and memory efficient, and is simple to use. Primary core functions have been posted, and additional advanced and useful XML-related utilities will be added. Released under MIT License.

Files:     xml_parse_lib.h,     xml_parse_lib.c,     and     examples.

The XML-Parse library contains functions for parsing and/or creating xml files in a variety of ways. You should use whichever set makes sense for your needs. The functions support the following alternative ways of working with XML files:

  1. Read whole xml-files into a tokenized tree-structure in memory, and then operate on, traverse, access, or further decode values out of the tree. Your custom application code is usually required to access and operate on the tokenized-values.
  2. Read xml-files, parse and interpret them as they are being read. Your custom application-specific code can be interspersed with the re-usable parsing calls to interpret, convert, operate-on or store values immediately as input-stream is read, instead of storing in an intermediate tokenized-tree structure. This method reduce time and memory requirements, and supports streaming operations.
  3. Build xml-tree structures with convenient reusable routines from data in your application, and or modify values in read-in trees.
  4. Write-out valid xml-files automatically from xml-trees that were constructed or read-into memory by your application.
  5. Check xml-trees against an arbitrary xml schema definition (XSD).

High-Level Functions: An example of using these functions to make a general-purpose xml-parser that will read any xml-file can be downloaded from: test_general_parser.c.

Medium-Level Functions:

First a note about terminology. Consider the following XML example:

  <tag1 attrib11="value11"> 
    <tag2> my contents2 </tag2>
In this example, there are two tag-elements: tag1 and tag2. The element tag1 has one attribute called attrib11. All attributes are name and value pairs. The second element-tag is contained within the first tag-element, because it occurs before the corresponding closing tag, and is therefore considered a child of the first tag-element. The second element-tag has contents equal to my contents2.

Low-Level Functions: Unit Converters

Examples - (These files are included in the download package.)

  1. General XML Streaming Reader Shell
  2. XML Test-file Generator
  3. General XML Automatic Parsing
  4. General XML Traversal

Download -

SourceForge.net Logo