Node Type
Name | Description |
---|---|
MXML_ELEMENT | XML element with attributes |
MXML_INTEGER | Integer value |
MXML_OPAQUE | Opaque string |
MXML_REAL | Real value |
MXML_TEXT | Text fragment |
Add a node to a tree.
void mxmlAdd( mxml_node_t * parent, int where, mxml_node_t * child, mxml_node_t * node);
Name | Description |
---|---|
parent | Parent node |
where | Where to add |
child | Child node for where |
node | Node to add |
Nothing.
Delete a node and all of its children.
void mxmlDelete( mxml_node_t * node);
Name | Description |
---|---|
node | Node |
Nothing.
Get an attribute.
const char * mxmlElementGetAttr( mxml_node_t * node, const char * name);
Name | Description |
---|---|
node | Element node |
name | Name of attribute |
Attribute value or NULL
Set an attribute.
void mxmlElementSetAttr( mxml_node_t * node, const char * name, const char * value);
Name | Description |
---|---|
node | Element node |
name | Name of attribute |
value | Attribute value |
Nothing.
Find the named element.
mxml_node_t * mxmlFindElement( mxml_node_t * node, mxml_node_t * top, const char * name, const char * attr, const char * value, int descend);
Name | Description |
---|---|
node | Current node |
top | Top node |
name | Element name or NULL for any |
attr | Attribute name, or NULL for none |
value | Attribute value, or NULL for any |
descend | Descend into tree? |
Element node or NULL
Load a file into an XML node tree.
mxml_node_t * mxmlLoadFile( mxml_node_t * top, FILE * fp, mxml_type_t (*cb)(mxml_node_t *));
Name | Description |
---|---|
top | Top node |
fp | File to read from |
(*cb)(mxml_node_t *) | Callback function |
First node
Create a new element node.
mxml_node_t * mxmlNewElement( mxml_node_t * parent, const char * name);
Name | Description |
---|---|
parent | Parent node |
name | Name of element |
New node
Create a new integer node.
mxml_node_t * mxmlNewInteger( mxml_node_t * parent, int integer);
Name | Description |
---|---|
parent | Parent node |
integer | Integer value |
New node
Create a new opaque string.
mxml_node_t * mxmlNewOpaque( mxml_node_t * parent, const char * opaque);
Name | Description |
---|---|
parent | Parent node |
opaque | Opaque string |
New node
Create a new real number node.
mxml_node_t * mxmlNewReal( mxml_node_t * parent, double real);
Name | Description |
---|---|
parent | Parent node |
real | Real number value |
New node
Create a new text fragment node.
mxml_node_t * mxmlNewText( mxml_node_t * parent, int whitespace, const char * string);
Name | Description |
---|---|
parent | Parent node |
whitespace | Leading whitespace? |
string | String |
New node
Remove a node from its parent.
void mxmlRemove( mxml_node_t * node);
Name | Description |
---|---|
node | Node to remove |
Nothing.
Save an XML tree to a file.
int mxmlSaveFile( mxml_node_t * node, FILE * fp, int (*cb)(mxml_node_t *int));
Name | Description |
---|---|
node | Node to write |
fp | File to write to |
(*cb)(mxml_node_t *int) | Whitespace callback |
0 on success, -1 on error
Walk to the next logical node in the tree.
mxml_node_t * mxmlWalkNext( mxml_node_t * node, mxml_node_t * top, int descend);
Name | Description |
---|---|
node | Current node |
top | Top node |
descend | Descend into tree? |
Next node or NULL
Walk to the previous logical node in the tree.
mxml_node_t * mxmlWalkPrev( mxml_node_t * node, mxml_node_t * top, int descend);
Name | Description |
---|---|
node | Current node |
top | Top node |
descend | Descend into tree? |
Previous node or NULL
Attribute Value
struct mxml_attr_s { char * name; char * value; };
Name | Description |
---|---|
name | Attribute name |
value | Attribute value |
Node
struct mxml_node_s { mxml_node_t * child; mxml_node_t * last_child; mxml_node_t * next; mxml_node_t * parent; mxml_node_t * prev; mxml_type_t type; mxml_value_t value; };
Name | Description |
---|---|
child | First child node |
last_child | Last child node |
next | Next node under same parent |
parent | Parent node |
prev | Previous node under same parent |
type | Node type |
value | Node value |
Text Value
struct mxml_text_s { char * string; int whitespace; };
Name | Description |
---|---|
string | Fragment string |
whitespace | Leading whitespace? |
Element Value
struct mxml_value_s { mxml_attr_t * attrs; char * name; int num_attrs; };
Name | Description |
---|---|
attrs | Attributes |
name | Name of element |
num_attrs | Number of attributes |
Attribute Value
typedef struct mxml_attr_s mxml_attr_t;
Element Value
typedef struct mxml_value_s mxml_element_t;
Text Value
typedef struct mxml_text_s mxml_text_t;
Node Type
typedef enum mxml_type_e mxml_type_t;
Node Value
typedef union mxml_value_u mxml_value_t;
Node Value
struct mxml_value_u { mxml_element_t element; int integer; char * opaque; double real; mxml_text_t text; };
Name | Description |
---|---|
element | Element |
integer | Integer number |
opaque | Opaque string |
real | Real number |
text | Text fragment |