e-xml-utils: Evolution-Data-Server Reference Manual

## e-xml-utils e-xml-utils |

## Functions

void | e_xml_initialize_in_main ()
xmlDoc * | e_xml_parse_file ()
gint | e_xml_save_file ()
xmlNode * | e_xml_get_child_by_name ()
xmlDoc * | e_xml_parse_data ()
xmlXPathContext * | e_xml_new_xpath_context_with_namespaces ()
void | e_xml_xpath_context_register_namespaces ()
xmlXPathObject * | e_xml_xpath_eval ()
gchar * | e_xml_xpath_eval_as_string ()
gboolean | e_xml_xpath_eval_exists ()

## Description

## Functions

### e_xml_initialize_in_main ()

    void
    e_xml_initialize_in_main (void);

Initializes libxml library global memory. This should be called in the main thread. The function does nothing, when it had been called already.

[skip]

Since: 3.26.2

### e_xml_parse_file ()

    xmlDoc *
    e_xml_parse_file (const gchar *filename);

Reads a local XML file and parses the contents into an XML document structure. If the XML file cannot be read or its contents are malformed, the function returns `NULL`.

[skip]

#### Parameters

filename | path to an XML file |

#### Returns

an XML document structure, or `NULL`.

[transfer full]

### e_xml_save_file ()

    gint
    e_xml_save_file (const gchar *filename,
                     xmlDoc *doc);

Writes the given XML document structure to the file given by `filename` . If an error occurs while saving, the function returns -1 and sets errno.

#### Parameters

filename | path to a file to save to |
doc | an XML document structure |

#### Returns

0 on success, -1 on failure

### e_xml_get_child_by_name ()

    xmlNode *
    e_xml_get_child_by_name (const xmlNode *parent,
                             const xmlChar *child_name);

Attempts to find a child element of `parent` named `child_name` . If no such child exists, the function returns `NULL`.

[skip]

#### Parameters

parent | an XML node structure |
child_name | element name of a child node |

#### Returns

a child XML node structure, or `NULL`.

[nullable]

### e_xml_parse_data ()

    xmlDoc *
    e_xml_parse_data (gconstpointer data,
                      gsize length);

Parses XML data into an xmlDocPtr. Free returned pointer with `xmlFreeDoc()`, when no longer needed.

[skip]

#### Parameters

data | an XML data. | [array length=length][element-type guint8]
length | length of data, should be greated than zero |

#### Returns

a new xmlDocPtr with parsed `data` , or `NULL` on error.

[nullable][transfer full]

Since: 3.26

### e_xml_new_xpath_context_with_namespaces ()

    xmlXPathContext *
    e_xml_new_xpath_context_with_namespaces
                                   (xmlDoc *doc,
                                    ...);

Creates a new xmlXPathContextPtr on `doc` with preregistered namespaces. The namepsaces are pair of (prefix, href), terminated by `NULL`.

[skip]

#### Parameters

doc | an xmlDocPtr |
... | `NULL`-terminated list of pairs (prefix, href) with namespaces |

#### Returns

a new xmlXPathContextPtr. Free the returned pointer with `xmlXPathFreeContext()` when no longer needed.

[transfer full]

Since: 3.26

### e_xml_xpath_context_register_namespaces ()

    void
    e_xml_xpath_context_register_namespaces
                                   (xmlXPathContext *xpath_ctx,
                                    const gchar *prefix,
                                    const gchar *href,
                                    ...);

Registers one or more additional namespaces. It's a caller's error to try to register a namespace with the same prefix again, unless the prefix uses the same namespace href.

[skip]

#### Parameters

xpath_ctx | an xmlXPathContextPtr |
prefix | namespace prefix |
href | namespace href |
... | `NULL`-terminated list of pairs (prefix, href) with additional namespaces |

Since: 3.26

### e_xml_xpath_eval ()

    xmlXPathObject *
    e_xml_xpath_eval (xmlXPathContext *xpath_ctx,
                      const gchar *format,
                      ...);

Evaluates path specified by `format` and returns its xmlXPathObjectPtr, in case the path evaluates to a non-empty node set. See also `e_xml_xpath_eval_as_string()` which evaluates the path to string.

[skip]

#### Parameters

xpath_ctx | an xmlXPathContextPtr |
format | printf-like format specifier of path to evaluate |
... | arguments for the `format` |

#### Returns

a new xmlXPathObjectPtr which references given path, or `NULL` if path cannot be found or when it evaluates to an empty nodeset. Free returned pointer with `xmlXPathFreeObject()`, when no longer needed.

[nullable][transfer full]

Since: 3.26

### e_xml_xpath_eval_as_string ()

    gchar *
    e_xml_xpath_eval_as_string (xmlXPathContext *xpath_ctx,
                                const gchar *format,
                                ...);

Evaluates path specified by `format` and returns its result as string, in case the path evaluates to a non-empty node set. See also `e_xml_xpath_eval()` which evaluates the path to an xmlXPathObjectPtr.

[skip]

#### Parameters

xpath_ctx | an xmlXPathContextPtr |
format | printf-like format specifier of path to evaluate |
... | arguments for the `format` |

#### Returns

a new string which contains value of the given path, or `NULL` if path cannot be found or when it evaluates to an empty nodeset. Free returned pointer with `g_free()`, when no longer needed.

[nullable][transfer full]

Since: 3.26

### e_xml_xpath_eval_exists ()

    gboolean
    e_xml_xpath_eval_exists (xmlXPathContext *xpath_ctx,
                             const gchar *format,
                             ...);

Evaluates path specified by `format` and returns whether it exists.

[skip]

#### Parameters

xpath_ctx | an xmlXPathContextPtr |
format | printf-like format specifier of path to evaluate |
... | arguments for the `format` |

#### Returns

`TRUE`, when the given XPath exists, `FALSE` otherwise.

Since: 3.26

## Types and Values