Contents

Classes

Enumerations


mxml_type_e

Node Type

Values

NameDescription
MXML_ELEMENTXML element with attributes
MXML_INTEGERInteger value
MXML_OPAQUEOpaque string
MXML_REALReal value
MXML_TEXTText fragment

Functions


mxmlAdd()

Add a node to a tree.

Syntax

void
mxmlAdd(
    mxml_node_t * parent,
    int where,
    mxml_node_t * child,
    mxml_node_t * node);

Arguments

NameDescription
parentParent node
whereWhere to add
childChild node for where
nodeNode to add

Returns

Nothing.


mxmlDelete()

Delete a node and all of its children.

Syntax

void
mxmlDelete(
    mxml_node_t * node);

Arguments

NameDescription
nodeNode

Returns

Nothing.


mxmlElementGetAttr()

Get an attribute.

Syntax

const char *
mxmlElementGetAttr(
    mxml_node_t * node,
    const char * name);

Arguments

NameDescription
nodeElement node
nameName of attribute

Returns

Attribute value or NULL


mxmlElementSetAttr()

Set an attribute.

Syntax

void
mxmlElementSetAttr(
    mxml_node_t * node,
    const char * name,
    const char * value);

Arguments

NameDescription
nodeElement node
nameName of attribute
valueAttribute value

Returns

Nothing.


mxmlFindElement()

Find the named element.

Syntax

mxml_node_t *
mxmlFindElement(
    mxml_node_t * node,
    mxml_node_t * top,
    const char * name,
    const char * attr,
    const char * value,
    int descend);

Arguments

NameDescription
nodeCurrent node
topTop node
nameElement name or NULL for any
attrAttribute name, or NULL for none
valueAttribute value, or NULL for any
descendDescend into tree?

Returns

Element node or NULL


mxmlLoadFile()

Load a file into an XML node tree.

Syntax

mxml_node_t *
mxmlLoadFile(
    mxml_node_t * top,
    FILE * fp,
    mxml_type_t (*cb)(mxml_node_t *));

Arguments

NameDescription
topTop node
fpFile to read from
(*cb)(mxml_node_t *)Callback function

Returns

First node


mxmlNewElement()

Create a new element node.

Syntax

mxml_node_t *
mxmlNewElement(
    mxml_node_t * parent,
    const char * name);

Arguments

NameDescription
parentParent node
nameName of element

Returns

New node


mxmlNewInteger()

Create a new integer node.

Syntax

mxml_node_t *
mxmlNewInteger(
    mxml_node_t * parent,
    int integer);

Arguments

NameDescription
parentParent node
integerInteger value

Returns

New node


mxmlNewOpaque()

Create a new opaque string.

Syntax

mxml_node_t *
mxmlNewOpaque(
    mxml_node_t * parent,
    const char * opaque);

Arguments

NameDescription
parentParent node
opaqueOpaque string

Returns

New node


mxmlNewReal()

Create a new real number node.

Syntax

mxml_node_t *
mxmlNewReal(
    mxml_node_t * parent,
    double real);

Arguments

NameDescription
parentParent node
realReal number value

Returns

New node


mxmlNewText()

Create a new text fragment node.

Syntax

mxml_node_t *
mxmlNewText(
    mxml_node_t * parent,
    int whitespace,
    const char * string);

Arguments

NameDescription
parentParent node
whitespaceLeading whitespace?
stringString

Returns

New node


mxmlRemove()

Remove a node from its parent.

Syntax

void
mxmlRemove(
    mxml_node_t * node);

Arguments

NameDescription
nodeNode to remove

Returns

Nothing.


mxmlSaveFile()

Save an XML tree to a file.

Syntax

int
mxmlSaveFile(
    mxml_node_t * node,
    FILE * fp,
    int (*cb)(mxml_node_t *int));

Arguments

NameDescription
nodeNode to write
fpFile to write to
(*cb)(mxml_node_t *int)Whitespace callback

Returns

0 on success, -1 on error


mxmlWalkNext()

Walk to the next logical node in the tree.

Syntax

mxml_node_t *
mxmlWalkNext(
    mxml_node_t * node,
    mxml_node_t * top,
    int descend);

Arguments

NameDescription
nodeCurrent node
topTop node
descendDescend into tree?

Returns

Next node or NULL


mxmlWalkPrev()

Walk to the previous logical node in the tree.

Syntax

mxml_node_t *
mxmlWalkPrev(
    mxml_node_t * node,
    mxml_node_t * top,
    int descend);

Arguments

NameDescription
nodeCurrent node
topTop node
descendDescend into tree?

Returns

Previous node or NULL

Structures


mxml_attr_s

Attribute Value

Definition

struct mxml_attr_s
{
  char * name;
  char * value;
};

Members

NameDescription
nameAttribute name
valueAttribute value


mxml_node_s

Node

Definition

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;
};

Members

NameDescription
childFirst child node
last_childLast child node
nextNext node under same parent
parentParent node
prevPrevious node under same parent
typeNode type
valueNode value


mxml_text_s

Text Value

Definition

struct mxml_text_s
{
  char * string;
  int whitespace;
};

Members

NameDescription
stringFragment string
whitespaceLeading whitespace?


mxml_value_s

Element Value

Definition

struct mxml_value_s
{
  mxml_attr_t * attrs;
  char * name;
  int num_attrs;
};

Members

NameDescription
attrsAttributes
nameName of element
num_attrsNumber of attributes

Types


mxml_attr_t

Attribute Value

Definition

typedef struct mxml_attr_s mxml_attr_t;

mxml_element_t

Element Value

Definition

typedef struct mxml_value_s mxml_element_t;

mxml_text_t

Text Value

Definition

typedef struct mxml_text_s mxml_text_t;

mxml_type_t

Node Type

Definition

typedef enum mxml_type_e mxml_type_t;

mxml_value_t

Node Value

Definition

typedef union mxml_value_u mxml_value_t;

Unions


mxml_value_u

Node Value

Definition

struct mxml_value_u
{
  mxml_element_t element;
  int integer;
  char * opaque;
  double real;
  mxml_text_t text;
};

Members

NameDescription
elementElement
integerInteger number
opaqueOpaque string
realReal number
textText fragment