EXmlDocument

EXmlDocument — An XML document wrapper

Functions

Types and Values

struct EXmlDocument

Object Hierarchy

    GObject
    ╰── EXmlDocument

Includes

#include <libedataserver/libedataserver.h>

Description

The EXmlDocument class wraps creation of XML documents.

Functions

e_xml_document_new ()

EXmlDocument *
e_xml_document_new (const gchar *ns_href,
                    const gchar *root_element);

Creates a new EXmlDocument with root element root_element and optionally also with set default namespace ns_href .

Parameters

ns_href

default namespace href to use, or NULL.

[nullable]

root_element

root element name

 

Returns

a new EXmlDocument; free it with g_object_unref(), when no longer needed.

[transfer full]

Since: 3.26


e_xml_document_get_xmldoc ()

xmlDoc *
e_xml_document_get_xmldoc (EXmlDocument *xml);

Parameters

xml

an EXmlDocument

 

Returns

Underlying xmlDocPtr.

[transfer none]

Since: 3.26


e_xml_document_get_content ()

gchar *
e_xml_document_get_content (const EXmlDocument *xml,
                            gsize *out_length);

Gets content of the xml as string. The string is nul-terminated, but if out_length is also provided, then it doesn't contain this additional nul character.

Parameters

xml

an EXmlDocument

 

out_length

optional return location for length of the content, or NULL.

[out][nullable]

Returns

Content of the xml as newly allocated string. Free it with g_free(), when no longer needed.

[transfer full]

Since: 3.26


e_xml_document_add_namespaces ()

void
e_xml_document_add_namespaces (EXmlDocument *xml,
                               const gchar *ns_prefix,
                               const gchar *ns_href,
                               ...);

Adds one or more namespaces to xml , which can be referenced later by ns_href . The caller should take care that neither used ns_prefix , nor ns_href , is already used by xml .

Parameters

xml

an EXmlDocument

 

ns_prefix

namespace prefix to use for this namespace

 

ns_href

namespace href

 

...

NULL-terminated pairs of (ns_prefix, ns_href)

 

Since: 3.26


e_xml_document_start_element ()

void
e_xml_document_start_element (EXmlDocument *xml,
                              const gchar *ns_href,
                              const gchar *name);

Starts a new non-text element as a child of the current element. Each such call should be ended with corresponding e_xml_document_end_element(). Use NULL ns_href , to use the default namespace, otherwise either previously added namespace with the same href from e_xml_document_add_namespaces() is picked, or a new namespace with generated prefix is added.

To start a text node use e_xml_document_start_text_element().

Parameters

xml

an EXmlDocument

 

ns_href

optional namespace href for the new element, or NULL.

[nullable]

name

name of the new element

 

Since: 3.26


e_xml_document_start_text_element ()

void
e_xml_document_start_text_element (EXmlDocument *xml,
                                   const gchar *ns_href,
                                   const gchar *name);

Starts a new text element as a child of the current element. Each such call should be ended with corresponding e_xml_document_end_element(). Use NULL ns_href , to use the default namespace, otherwise either previously added namespace with the same href from e_xml_document_add_namespaces() is picked, or a new namespace with generated prefix is added.

To start a non-text node use e_xml_document_start_element().

Parameters

xml

an EXmlDocument

 

ns_href

optional namespace href for the new element, or NULL.

[nullable]

name

name of the new element

 

Since: 3.26


e_xml_document_end_element ()

void
e_xml_document_end_element (EXmlDocument *xml);

This is a pair function for e_xml_document_start_element() and e_xml_document_start_text_element(), which changes current element to the parent of that element.

Parameters

xml

an EXmlDocument

 

Since: 3.26


e_xml_document_add_empty_element ()

void
e_xml_document_add_empty_element (EXmlDocument *xml,
                                  const gchar *ns_href,
                                  const gchar *name);

Adds an empty element, which is an element with no attribute and no value.

It's the same as calling e_xml_document_start_element() immediately followed by e_xml_document_end_element().

Parameters

xml

an EXmlDocument

 

ns_href

optional namespace href for the new element, or NULL.

[nullable]

name

name of the new element

 

Since: 3.26


e_xml_document_add_attribute ()

void
e_xml_document_add_attribute (EXmlDocument *xml,
                              const gchar *ns_href,
                              const gchar *name,
                              const gchar *value);

Adds a new attribute to the current element. Use NULL ns_href , to use the default namespace, otherwise either previously added namespace with the same href from e_xml_document_add_namespaces() is picked, or a new namespace with generated prefix is added.

Parameters

xml

an EXmlDocument

 

ns_href

optional namespace href for the new attribute, or NULL.

[nullable]

name

name of the attribute

 

value

value of the attribute

 

Since: 3.26


e_xml_document_add_attribute_int ()

void
e_xml_document_add_attribute_int (EXmlDocument *xml,
                                  const gchar *ns_href,
                                  const gchar *name,
                                  gint64 value);

Adds a new attribute with an integer value to the current element. Use NULL ns_href , to use the default namespace, otherwise either previously added namespace with the same href from e_xml_document_add_namespaces() is picked, or a new namespace with generated prefix is added.

Parameters

xml

an EXmlDocument

 

ns_href

optional namespace href for the new attribute, or NULL.

[nullable]

name

name of the attribute

 

value

integer value of the attribute

 

Since: 3.26


e_xml_document_add_attribute_double ()

void
e_xml_document_add_attribute_double (EXmlDocument *xml,
                                     const gchar *ns_href,
                                     const gchar *name,
                                     gdouble value);

Adds a new attribute with a double value to the current element. Use NULL ns_href , to use the default namespace, otherwise either previously added namespace with the same href from e_xml_document_add_namespaces() is picked, or a new namespace with generated prefix is added.

Parameters

xml

an EXmlDocument

 

ns_href

optional namespace href for the new attribute, or NULL.

[nullable]

name

name of the attribute

 

value

double value of the attribute

 

Since: 3.26


e_xml_document_add_attribute_time ()

void
e_xml_document_add_attribute_time (EXmlDocument *xml,
                                   const gchar *ns_href,
                                   const gchar *name,
                                   time_t value);

Adds a new attribute with a time_t value in ISO 8601 format to the current element. The format is "YYYY-MM-DDTHH:MM:SSZ". Use NULL ns_href , to use the default namespace, otherwise either previously added namespace with the same href from e_xml_document_add_namespaces() is picked, or a new namespace with generated prefix is added.

Parameters

xml

an EXmlDocument

 

ns_href

optional namespace href for the new attribute, or NULL.

[nullable]

name

name of the attribute

 

value

time_t value of the attribute

 

Since: 3.26


e_xml_document_add_attribute_time_ical ()

void
e_xml_document_add_attribute_time_ical
                               (EXmlDocument *xml,
                                const gchar *ns_href,
                                const gchar *name,
                                time_t value);

Adds a new attribute with a time_t value in iCalendar format to the current element. The format is "YYYYMMDDTHHMMSSZ". Use NULL ns_href , to use the default namespace, otherwise either previously added namespace with the same href from e_xml_document_add_namespaces() is picked, or a new namespace with generated prefix is added.

Parameters

xml

an EXmlDocument

 

ns_href

optional namespace href for the new attribute, or NULL.

[nullable]

name

name of the attribute

 

value

time_t value of the attribute

 

Since: 3.32


e_xml_document_write_int ()

void
e_xml_document_write_int (EXmlDocument *xml,
                          gint64 value);

Writes value as content of the current element.

Parameters

xml

an EXmlDocument

 

value

value to write as the content

 

Since: 3.26


e_xml_document_write_double ()

void
e_xml_document_write_double (EXmlDocument *xml,
                             gdouble value);

Writes value as content of the current element.

Parameters

xml

an EXmlDocument

 

value

value to write as the content

 

Since: 3.26


e_xml_document_write_base64 ()

void
e_xml_document_write_base64 (EXmlDocument *xml,
                             const gchar *value,
                             gint len);

Writes value of length len , encoded to base64, as content of the current element.

Parameters

xml

an EXmlDocument

 

value

value to write as the content

 

len

length of value

 

Since: 3.26


e_xml_document_write_time ()

void
e_xml_document_write_time (EXmlDocument *xml,
                           time_t value);

Writes value in ISO 8601 format as content of the current element. The format is "YYYY-MM-DDTHH:MM:SSZ".

Parameters

xml

an EXmlDocument

 

value

value to write as the content

 

Since: 3.26


e_xml_document_write_string ()

void
e_xml_document_write_string (EXmlDocument *xml,
                             const gchar *value);

Writes value as content of the current element.

Parameters

xml

an EXmlDocument

 

value

value to write as the content

 

Since: 3.26


e_xml_document_write_buffer ()

void
e_xml_document_write_buffer (EXmlDocument *xml,
                             const gchar *value,
                             gint len);

Writes value of length len as content of the current element.

Parameters

xml

an EXmlDocument

 

value

value to write as the content

 

len

length of value

 

Since: 3.26

Types and Values

struct EXmlDocument

struct EXmlDocument;

Contains only private data that should be read and manipulated using the functions below.

Since: 3.26