## XML Template Functions XML Template Functions — Functions to create and parse glabels XML template nodes and files |

## Synopsis

    #include <libglabels/xml-templates.h>

    GList *             lgl_xml_template_read_templates_from_file
                                                            (const gchar *utf8_filename);
    GList *             lgl_xml_template_parse_templates_doc
                                                            (const xmlDocPtr templates_doc);
    lglTemplate *       lgl_xml_template_parse_template_node
                                                            (const xmlNodePtr template_node);
    gint                lgl_xml_template_write_templates_to_file
                                                            (GList *templates,
                                                             const gchar *utf8_filename);
    gint                lgl_xml_template_write_template_to_file
                                                            (const lglTemplate *template,
                                                             const gchar *utf8_filename);
    void                lgl_xml_template_create_template_node
                                                            (const lglTemplate *template,
                                                             xmlNodePtr root,
                                                             const xmlNsPtr ns);

## Description

This section describes a number of functions for creating and parsing glabels XML template nodes and files. Template nodes are used in both template files and document files.

## Details

### lgl_xml_template_read_templates_from_file ()

    GList *             lgl_xml_template_read_templates_from_file
                                                            (const gchar *utf8_filename);

Read glabels templates from template file.

`utf8_filename` : | Filename of papers file (name encoded as UTF-8)
Returns : | a list of lglTemplate structures.

### lgl_xml_template_parse_templates_doc ()

    GList *             lgl_xml_template_parse_templates_doc
                                                            (const xmlDocPtr templates_doc);

Read glabels templates from a libxml xmlDocPtr tree.

`templates_doc` : | libxml xmlDocPtr tree, representing template file.
Returns : | a list of lglTemplate structures.

### lgl_xml_template_parse_template_node ()

    lglTemplate *       lgl_xml_template_parse_template_node
                                                            (const xmlNodePtr template_node);

Read a single glabels template from a libxml xmlNodePtr node.

`template_node` : | libxml xmlNodePtr template node from a xmlDocPtr tree.
Returns : | a pointer to a newly created lglTemplate structure.

### lgl_xml_template_write_templates_to_file ()

    gint                lgl_xml_template_write_templates_to_file
                                                            (GList *templates,
                                                             const gchar *utf8_filename);

Write a list of lglTemplate structures to a glabels XML template file.

`templates` : | List of lglTemplate structures
`utf8_filename` : | Filename of templates file (name encoded as UTF-8)
Returns : | the number of bytes written or -1 in case of failure

### lgl_xml_template_write_template_to_file ()

    gint                lgl_xml_template_write_template_to_file
                                                            (const lglTemplate *template,
                                                             const gchar *utf8_filename);

Write a single lglTemplate structures to a glabels XML template file.

`template` : | lglTemplate structure to be written
`utf8_filename` : | Filename of templates file (name encoded as UTF-8)
Returns : | the number of bytes written or -1 in case of failure

### lgl_xml_template_create_template_node ()

    void                lgl_xml_template_create_template_node
                                                            (const lglTemplate *template,
                                                             xmlNodePtr root,
                                                             const xmlNsPtr ns);

Add a single lglTemplate child node to given xmlNodePtr.

`template` : | lglTemplate structure to be written
`root` : | parent node to receive new child node
`ns` : | a libxml xmlNsPtr