Add a node to a tree.
Adds the specified node to the parent. If the child argument is not
NULL, puts the new node before or after the specified child depending
on the value of the where argument. If the child argument is NULL,
puts the new node at the beginning of the child list (MXML_ADD_BEFORE)
or at the end of the child list (MXML_ADD_AFTER). The constant
MXML_ADD_TO_PARENT can be used to specify a NULL child pointer.
mxml_node_t *
Parent node
int
Where to add, MXML_ADD_BEFORE or MXML_ADD_AFTER
mxml_node_t *
Child node for where or MXML_ADD_TO_PARENT
mxml_node_t *
Node to add
Delete a node and all of its children.
If the specified node has a parent, this function first removes the
node from its parent using the mxmlRemove() function.
mxml_node_t *
Node to delete
const char *
Attribute value or NULL
Get an attribute.
This function returns NULL if the node is not an element or the
named attribute does not exist.
mxml_node_t *
Element node
const char *
Name of attribute
Set an attribute.
If the named attribute already exists, the value of the attribute
is replaced by the new string value. The string value is copied
into the element node. This function does nothing if the node is
not an element.
mxml_node_t *
Element node
const char *
Name of attribute
const char *
Attribute value
Add a callback to convert entities to Unicode.
int
Callback function to add
const char *
Entity name or NULL
Get the name that corresponds to the character value.
If val does not need to be represented by a named entity, NULL is returned.
int
Character value
int
Character value or -1 on error
Get the character corresponding to a named entity.
The entity name can also be a numeric constant. -1 is returned if the
name is not known.
const char *
Entity name
Remove a callback.
int
Callback function to remove
mxml_node_t *
Element node or NULL
Find the named element.
The search is constrained by the name, attribute name, and value; any
NULL names or values are treated as wildcards, so different kinds of
searches can be implemented by looking for all elements of a given name
or all elements with a specific attribute. The descend argument determines
whether the search descends into child nodes; normally you will use
MXML_DESCEND_FIRST for the initial search and MXML_NO_DESCEND to find
additional direct descendents of the node. The top node argument
constrains the search to a particular node's children.
mxml_node_t *
Current node
mxml_node_t *
Top node
const char *
Element name or NULL for any
const char *
Attribute name, or NULL for none
const char *
Attribute value, or NULL for any
int
Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
Delete an index.
mxml_index_t *
Index to delete
mxml_node_t *
Next node or NULL if there is none
Return the next node in the index.
Nodes are returned in the sorted order of the index.
mxml_index_t *
Index to enumerate
mxml_node_t *
Node or NULL if none found
Find the next matching node.
You should call mxmlIndexReset() prior to using this function for
the first time with a particular set of "element" and "value"
strings. Passing NULL for both "element" and "value" is equivalent
to calling mxmlIndexEnum().
mxml_index_t *
Index to search
const char *
Element name to find, if any
const char *
Attribute value, if any
mxml_index_t *
New index
Create a new index.
The index will contain all nodes that contain the named element and/or
attribute. If both "element" and "attr" are NULL, then the index will
contain a sorted list of the elements in the node tree. Nodes are
sorted by element name and optionally by attribute value if the "attr"
argument is not NULL.
mxml_node_t *
XML node tree
const char *
Element to index or NULL for all
const char *
Attribute to index or NULL for none
mxml_node_t *
First node or NULL if there is none
Reset the enumeration/find pointer in the index and
return the first node in the index.
This function should be called prior to using mxmlIndexEnum() or
mxmlIndexFind() for the first time.
mxml_index_t *
Index to reset
mxml_node_t *
First node or NULL if the file could not be read.
Load a file into an XML node tree.
The nodes in the specified file are added to the specified top node.
If no top node is provided, the XML file MUST be well-formed with a
single parent node like <?xml> for the entire file. The callback
function returns the value type that should be used for child nodes.
If MXML_NO_CALLBACK is specified then all child nodes will be either
MXML_ELEMENT or MXML_TEXT nodes.
The constants MXML_INTEGER_CALLBACK, MXML_OPAQUE_CALLBACK,
MXML_REAL_CALLBACK, and MXML_TEXT_CALLBACK are defined for loading
child nodes of the specified type.
mxml_node_t *
Top node
FILE *
File to read from
mxml_type_t
Callback function or MXML_NO_CALLBACK
mxml_node_t *
First node or NULL if the string has errors.
Load a string into an XML node tree.
The nodes in the specified string are added to the specified top node.
If no top node is provided, the XML string MUST be well-formed with a
single parent node like <?xml> for the entire string. The callback
function returns the value type that should be used for child nodes.
If MXML_NO_CALLBACK is specified then all child nodes will be either
MXML_ELEMENT or MXML_TEXT nodes.
The constants MXML_INTEGER_CALLBACK, MXML_OPAQUE_CALLBACK,
MXML_REAL_CALLBACK, and MXML_TEXT_CALLBACK are defined for loading
child nodes of the specified type.
mxml_node_t *
Top node
const char *
String to load
mxml_type_t
Callback function or MXML_NO_CALLBACK
mxml_node_t *
New node
Create a new element node.
The new element node is added to the end of the specified parent's child
list. The constant MXML_NO_PARENT can be used to specify that the new
element node has no parent.
mxml_node_t *
Parent node or MXML_NO_PARENT
const char *
Name of element
mxml_node_t *
New node
Create a new integer node.
The new integer node is added to the end of the specified parent's child
list. The constant MXML_NO_PARENT can be used to specify that the new
integer node has no parent.
mxml_node_t *
Parent node or MXML_NO_PARENT
int
Integer value
mxml_node_t *
New node
Create a new opaque string.
The new opaque node is added to the end of the specified parent's child
list. The constant MXML_NO_PARENT can be used to specify that the new
opaque node has no parent. The opaque string must be nul-terminated and
is copied into the new node.
mxml_node_t *
Parent node or MXML_NO_PARENT
const char *
Opaque string
mxml_node_t *
New node
Create a new real number node.
The new real number node is added to the end of the specified parent's
child list. The constant MXML_NO_PARENT can be used to specify that
the new real number node has no parent.
mxml_node_t *
Parent node or MXML_NO_PARENT
double
Real number value
mxml_node_t *
New node
Create a new text fragment node.
The new text node is added to the end of the specified parent's child
list. The constant MXML_NO_PARENT can be used to specify that the new
text node has no parent. The whitespace parameter is used to specify
whether leading whitespace is present before the node. The text
string must be nul-terminated and is copied into the new node.
mxml_node_t *
Parent node or MXML_NO_PARENT
int
1 = leading whitespace, 0 = no whitespace
const char *
String
mxml_node_t *
New node
Create a new formatted text fragment node.
The new text node is added to the end of the specified parent's child
list. The constant MXML_NO_PARENT can be used to specify that the new
text node has no parent. The whitespace parameter is used to specify
whether leading whitespace is present before the node. The format
string must be nul-terminated and is formatted into the new node.
mxml_node_t *
Parent node or MXML_NO_PARENT
int
1 = leading whitespace, 0 = no whitespace
const char *
Printf-style frmat string
Additional args as needed
Remove a node from its parent.
Does not free memory used by the node - use mxmlDelete() for that.
This function does nothing if the node has no parent.
mxml_node_t *
Node to remove
char *
Allocated string or NULL
Save an XML node tree to an allocated string.
This function returns a pointer to a string containing the textual
representation of the XML node tree. The string should be freed
using the free() function when you are done with it. NULL is returned
if the node would produce an empty string or if the string cannot be
allocated.
mxml_node_t *
Node to write
const char *
Whitespace callback or MXML_NO_CALLBACK
int
0 on success, -1 on error.
Save an XML tree to a file.
The callback argument specifies a function that returns a whitespace
character or nul (0) before and after each element. If MXML_NO_CALLBACK
is specified, whitespace will only be added before MXML_TEXT nodes
with leading whitespace and before attribute names inside opening
element tags.
mxml_node_t *
Node to write
FILE *
File to write to
const char *
Whitespace callback or MXML_NO_CALLBACK
int
Size of string
Save an XML node tree to a string.
This function returns the total number of bytes that would be
required for the string but only copies (bufsize - 1) characters
into the specified buffer.
mxml_node_t *
Node to write
char *
String buffer
int
Size of string buffer
const char *
Whitespace callback or MXML_NO_CALLBACK
int
0 on success, -1 on failure
Set the name of an element node.
The node is not changed if it is not an element node.
mxml_node_t *
Node to set
const char *
New name string
Set the error message callback.
void
Error callback function
int
0 on success, -1 on failure
Set the value of an integer node.
The node is not changed if it is not an integer node.
mxml_node_t *
Node to set
int
Integer value
int
0 on success, -1 on failure
Set the value of an opaque node.
The node is not changed if it is not an opaque node.
mxml_node_t *
Node to set
const char *
Opaque string
int
0 on success, -1 on failure
Set the value of a real number node.
The node is not changed if it is not a real number node.
mxml_node_t *
Node to set
double
Real number value
int
0 on success, -1 on failure
Set the value of a text node.
The node is not changed if it is not a text node.
mxml_node_t *
Node to set
int
1 = leading whitespace, 0 = no whitespace
const char *
String
int
0 on success, -1 on failure
Set the value of a text node to a formatted string.
The node is not changed if it is not a text node.
mxml_node_t *
Node to set
int
1 = leading whitespace, 0 = no whitespace
const char *
Printf-style format string
Additional arguments as needed
mxml_node_t *
Next node or NULL
Walk to the next logical node in the tree.
The descend argument controls whether the first child is considered
to be the next node. The top node argument constrains the walk to
the node's children.
mxml_node_t *
Current node
mxml_node_t *
Top node
int
Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
mxml_node_t *
Previous node or NULL
Walk to the previous logical node in the tree.
The descend argument controls whether the previous node's last child
is considered to be the previous node. The top node argument constrains
the walk to the node's children.
mxml_node_t *
Current node
mxml_node_t *
Top node
int
Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
An XML element attribute value.
char *
Attribute name
char *
Attribute value
struct mxml_attr_s
An XML element attribute value.
struct mxml_value_s
An XML element value.
An XML node index.
int
Allocated nodes in index
char *
Attribute used for indexing or NULL
int
Current node
mxml_node_t **
Node array
int
Number of nodes in index
struct mxml_index_s
An XML node index.
An XML node.
struct mxml_node_s *
First child node
struct mxml_node_s *
Last child node
struct mxml_node_s *
Next node under same parent
struct mxml_node_s *
Parent node
struct mxml_node_s *
Previous node under same parent
mxml_type_t
Node type
mxml_value_t
Node value
struct mxml_node_s
An XML node.
An XML text value.
char *
Fragment string
int
Leading whitespace?
struct mxml_text_s
An XML text value.
The XML node type.
XML element with attributes
Integer value
Opaque string
Real value
Text fragment
enum mxml_type_e
The XML node type.
An XML element value.
mxml_attr_t *
Attributes
char *
Name of element
int
Number of attributes
union mxml_value_u
An XML node value.
An XML node value.
mxml_element_t
Element
int
Integer number
char *
Opaque string
double
Real number
mxml_text_t
Text fragment
static int