## e2k-xml-utils e2k-xml-utils — XML utility functions |

## Synopsis

    xmlDoc *            e2k_parse_xml                       (const gchar *buf,
                                                             gint len);
    xmlDoc *            e2k_parse_html                      (const gchar *buf,
                                                             gint len);
    #define             E2K_IS_NODE                         (node,
                                                             nspace,
                                                             nname)

    #define             E2K_XML_HEADER
    void                e2k_g_string_append_xml_escaped     (GString *string,
                                                             const gchar *value);

    xmlNode *           e2k_xml_find                        (xmlNode *node,
                                                             const gchar *name);
    xmlNode *           e2k_xml_find_in                     (xmlNode *node,
                                                             xmlNode *top,
                                                             const gchar *name);

## Description

## Details

### e2k_parse_xml ()

    xmlDoc *            e2k_parse_xml                       (const gchar *buf,
                                                             gint len);

Parses the XML document in `buf`.

`buf` : | the data to parse
`len` : | the length of the buffer, or -1 if it is '\0'-terminated
Returns : | a pointer to an xmlDoc

### e2k_parse_html ()

    xmlDoc *            e2k_parse_html                      (const gchar *buf,
                                                             gint len);

Parses the HTML document in `buf`.

`buf` : | the data to parse
`len` : | the length of the buffer, or -1 if it is '\0'-terminated
Returns : | a pointer to an xmlDoc

### E2K_IS_NODE()

    #define             E2K_IS_NODE(node, nspace, nname)

`node` : |
`nspace` : |
`nname` : |

### E2K_XML_HEADER

    #define             E2K_XML_HEADER

### e2k_g_string_append_xml_escaped ()

    void                e2k_g_string_append_xml_escaped     (GString *string,
                                                             const gchar *value);

Appends `value` to `string`, escaping any characters that can't appear unencoded in XML text (eg, "<").

`string` : | a `GString` containing XML data
`value` : | data to append to `string`

### e2k_xml_find ()

    xmlNode *           e2k_xml_find                        (xmlNode *node,
                                                             const gchar *name);

Starts or continues a pre-order depth-first search of an xml document for an element named `name`. `node` is used as the starting point of the search, but is not examined itself.

To search the complete document, pass the root node of the document as `node` on the first call, and then on each successive call, pass the previous match as `node`.

`node` : | a node of an xml document
`name` : | the name of the element to find
Returns : | the first matching element after `node`, or `NULL` when there are no more matches.

### e2k_xml_find_in ()

    xmlNode *           e2k_xml_find_in                     (xmlNode *node,
                                                             xmlNode *top,
                                                             const gchar *name);

Starts or continues a pre-order depth-first search of a subset of an xml document for an element named `name`. `node` is used as the starting point of the search, but is not examined itself. `top` is the upper-most node that will be examined.

To search the complete tree under a given node, pass that node as both `node` and `top` on the first call, and then on each successive call, pass the previous match as `node` (with the original node still as `top`).

`node` : | a node of an xml document
`top` : | top of the search space
`name` : | the name of the element to find
Returns : | the first matching element after `node`, or `NULL` when there are no more matches.