Skip to content

stelmlu/xml-tokenizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xml_tokenizer.h

This is a single-header-file STB-style library that tokenize xml file for C (also works in C++)

The easiest way to install the library to your C/C++ project is to copy 'n' paste the xml_tokenizer.h to your project and do this in one C or C++ file:

#define XML_TOKENIZER_IMPLEMENTATION
#include "xml_tokenizer.h"

Compile-time Options

These defines only need to be set in the file containing XML_TOKENIZER_IMPLEMENTATION

#define XML_REALLOC(context,ptr,size) better_realloc
#define XML_FREE(context,ptr)         better_free

By default the stdlib realloc() and free() is used. You can defines your own by defining these symbols. You must either define both, or neither.

Note that at the moment, 'context' will always be NULL.

#define XML_FOPEN(fp,filename,mode) better_fopen
#define XML_FGETC(fp)               better_fgetc
#define XML_FCLOSE(fp)              better_fclose

By default the stdlib fopen(), fgetc() and fclose() are used. You can defines you own by defining these symbols. You most either define all three, or neither.

Example

You can find examples how to parser a book_cataloge.xml file that contains a book catalog using C and C++ (C++11).

example/parser_catalog.c
example/xml_dom.hpp

License

See LICENSE.txt