This is the reference documentation for using Alo to output XML documents. It is a simple to use library that reduces the amount of code needed to output XML.
The header file alo.h declares the Alo API. For more information and examples on using Alo, see the Tutorial and explore the provided test code.
Open an Alo document for output.
int16_t alo_open(alo_doc_info **doc, const char *file_name, uint32_t options,...)
the document to output to, allocated by alo_open
the filename to output to
options for outputting, like xml declarations and if to append to a file
0 if there is no error. errno can be checked to see if fopen had an error
Start output to the file named, outputting a declaration along with all the arguments if desired.
Close an Alo document.
void alo_close(alo_doc_info *doc)
Close any unfinished markup. Close the file written to. Free any memory used. Subsequent calls to this doc will not succeed.
Output some formatted XML data to the Alo document.
int16_t alo_out(alo_doc_info *doc, int16_t level, const char *format,...)
the document to output to
which XML element in the document to output to
C string containing the text, XML instructions, and printf to output. This indicates how to interpret the following arguments.
Output data to the doc at the level according to the format specified. The format is a C string containing text, XML instructions to create XML structures, and printf like rules to output arguments as formatted text.
Text is output as is, except the characters &<>" are output as XML entities.
The syntax of an XML instruction is:
XML Instruction = \^[eaCDP]
Printf formats = %[flag][width][.precision][lh]?[scdiuxX]
If the level is not the current level, then the levels are closed until the correct level is reached. If the correct level is not reached, then DOLATER.
The alo_doc_info structure contains information about the XML document being outputted. It is created by alo_open, passed to alo_out, and destroyed by alo_close. After destruction it is invalid to use it.
typedef struct alo_doc_info alo_doc_info
Only simple output is needed for new XML file.
Append the XML to the file specified.
Otherwise alo_open will truncate the file if it already exists.
Output a XML declaration at the start of the document.
Use this when opening complete XML documents. It's useful to not use it when just writing XML fragments. If a version is not specified (as the first argument), then version="1.0" will be added as required to be a well-formed XML document.
Convert output from ISO-8859-1 to utf-8.
Useful to keep XML output in legacy environments as portable as possible.
Status of it's inclusion into the API is experimental until experience shows enough apps justify permanent inclusion.