Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

xmlt.h File Reference

Functions and data structures for parsing and handling XML data. More...

#include "slist.h"
#include "dictionary.h"

Include dependency graph for xmlt.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  _xml_node
struct  xml_attribute
 Every tag has a list of attributes, which are key-value pairs as defined in this struct. More...


Defines

#define XML_UNKNOWN_TAG   -1
 Tags that were not recognized get this value.

#define XML_UNKNOWN_ATTRIBUTE   -1
 Attributes that were not recognized get this value.


Enumerations

enum  xml_node_t
 Type of XML node, used in the xml_node struct.


Functions

void * xmlt_create_context (void(*callback)(void *, xml_node *), void *cb_data, dictionary *tags, dictionary *attribs)
 Create a context for parsing an XML stream.

int xmlt_parse (void *context, const char *data, size_t len)
 Parse a chunk of XML data.

void xmlt_free_context (void *context)
 Free all memory associated with a particular context.

void xmlt_free_document (xml_node *doc)
 Free all memory associated with a particular document.

void xmlt_rescan_document (xml_node *doc, dictionary *tags, dictionary *attribs)
 Try to identify the unknown tags and attributes using a different set of dictionaries.

xml_node * xmlt_get_next (xml_node *iter, xml_node *doc)
 Get the next node in the document, depth first.

xml_node * xmlt_get_next_shallow (xml_node *iter)
 Get the next node in the document, without descending.


Detailed Description

Functions and data structures for parsing and handling XML data.

Definition in file xmlt.h.


Define Documentation

#define XML_UNKNOWN_ATTRIBUTE   -1
 

Attributes that were not recognized get this value.

This value could be replaced later on by xmlt_rescan_document.

Definition at line 41 of file xmlt.h.

#define XML_UNKNOWN_TAG   -1
 

Tags that were not recognized get this value.

This value could be replaced later on by xmlt_rescan_document.

Definition at line 37 of file xmlt.h.


Function Documentation

void* xmlt_create_context void(*    callback)(void *, xml_node *),
void *    cb_data,
dictionary   tags,
dictionary   attribs
 

Create a context for parsing an XML stream.

Whenever a complete document was received, callback is invoked with the provided cb_data, and the root tag of the document. The dictionaries for tags and attributes are used for looking up tag names and attribute keys. (These are stored as an integer, not as the complete string, for speed and memory efficiency.)

Parameters:
callback  This function will be called when a complete document was parsed. A document is considered to be complete whenever the root tag is closed.
cb_data  An extra parameter that will be passed to callback as well.
tags  A dictionary with all recognized tags and their respective index values.
attribs  A dictionary with all recognized attributes and their respective index values.

Definition at line 279 of file xmlt.c.

void xmlt_free_context void *    context
 

Free all memory associated with a particular context.

Parameters:
context  Pointer to a parser context, as returned by xmlt_create_context.

Definition at line 331 of file xmlt.c.

void xmlt_free_document xml_node *    doc
 

Free all memory associated with a particular document.

Parameters:
doc  Pointer to a document.

Definition at line 339 of file xmlt.c.

xml_node* xmlt_get_next xml_node *    iter,
xml_node *    doc
 

Get the next node in the document, depth first.

Parameters:
iter  Pointer to the current node.
doc  Document to traverse.
Returns:
Pointer to the next node, or NULL if iter was the last node.

Definition at line 368 of file xmlt.c.

xml_node* xmlt_get_next_shallow xml_node *    iter
 

Get the next node in the document, without descending.

Parameters:
iter  Pointer to the current node.
Returns:
Pointer to the next node, or NULL if iter was the last node in this level.

Definition at line 394 of file xmlt.c.

int xmlt_parse void *    context,
const char *    data,
size_t    len
 

Parse a chunk of XML data.

Parameters:
context  Pointer to a parser context, as returned by xmlt_create_context.
data  Pointer to some XML data.
len  Size of the XML data.
Returns:
1 if the data could be successfully parsed, 0 if not.

Definition at line 307 of file xmlt.c.

void xmlt_rescan_document xml_node *    doc,
dictionary   tags,
dictionary   attribs
 

Try to identify the unknown tags and attributes using a different set of dictionaries.

Parameters:
doc  Document to scan.
tags  Dictionary to use for tags.
attribs  Dictionary to use for attribs.

Definition at line 411 of file xmlt.c.


Generated on Sun Feb 16 23:40:04 2003 for FreeLCD by doxygen1.2.18