GXmlDocument

GXmlDocument — Interface to handle XML documents.

Functions

Types and Values

Description

Provides basic interfaces to read and create XML documents.

Functions

gxml_document_create_element ()

GXmlNode *
gxml_document_create_element (GXmlDocument *self,
                              const gchar *name,
                              GError **error);

This method should create a new GXmlElement.

Is a matter of you to add as a child to any other GXmlNode.

Parameters

self

the GXmlDocument instance

 

name

 

 

error

location to store the error occuring, or NULL to ignore

 

gxml_document_create_text ()

GXmlNode *
gxml_document_create_text (GXmlDocument *self,
                           const gchar *text);

Creates a new GXmlText.

Is a matter of you to add as a child to any other GXmlNode, like a GXmlElement node.

Parameters

self

the GXmlDocument instance

 

text

 

 

gxml_document_create_comment ()

GXmlNode *
gxml_document_create_comment (GXmlDocument *self,
                              const gchar *text);

Creates a new GXmlComment.

Is a matter of you to add as a child to any other GXmlNode, like a GXmlElement node.

Parameters

self

the GXmlDocument instance

 

text

 

 

gxml_document_create_cdata ()

GXmlNode *
gxml_document_create_cdata (GXmlDocument *self,
                            const gchar *text);

Creates a new GXmlCDATA.

Is a matter of you to add as a child to any other GXmlNode, like a GXmlElement node.

Parameters

self

the GXmlDocument instance

 

text

 

 

gxml_document_create_pi ()

GXmlNode *
gxml_document_create_pi (GXmlDocument *self,
                         const gchar *target,
                         const gchar *data);

Creates a new GXmlProcessingInstruction.

Is a matter of you to add as a child to any other GXmlNode, like a GXmlElement node.

Parameters

self

the GXmlDocument instance

 

target

 

 

data

 

 

gxml_document_save ()

gboolean
gxml_document_save (GXmlDocument *self,
                    GCancellable *cancellable,
                    GError **error);

Save this GXmlDocument to "file"

If "file" doesn't exists, it creates a new file to save to.

Parameters

self

the GXmlDocument instance

 

cancellable

 

 

error

location to store the error occuring, or NULL to ignore

 

gxml_document_save_as ()

gboolean
gxml_document_save_as (GXmlDocument *self,
                       GFile *f,
                       GCancellable *cancellable,
                       GError **error);

Save this GXmlDocument to given GFile

Parameters

self

the GXmlDocument instance

 

f

 

 

cancellable

 

 

error

location to store the error occuring, or NULL to ignore

 

gxml_document_get_indent ()

gboolean
gxml_document_get_indent (GXmlDocument *self);

Get and return the current value of the "indent" property.

Controls if writting this documents should use indent.

Parameters

self

the GXmlDocument instance to query

 

Returns

the value of the "indent" property


gxml_document_set_indent ()

void
gxml_document_set_indent (GXmlDocument *self,
                          gboolean value);

Set the value of the "indent" property to value .

Controls if writting this documents should use indent.

Parameters

self

the GXmlDocument instance to modify

 

value

the new value of the "indent" property

 

gxml_document_get_ns_top ()

gboolean
gxml_document_get_ns_top (GXmlDocument *self);

Get and return the current value of the "ns-top" property.

Controls if writting this documentsshould use namespaces declaration at root GXmlElement.

This removes full declaration at childs nodes, because they are just prefixed if a prefix was defined for namespace apply.

Parameters

self

the GXmlDocument instance to query

 

Returns

the value of the "ns-top" property


gxml_document_set_ns_top ()

void
gxml_document_set_ns_top (GXmlDocument *self,
                          gboolean value);

Set the value of the "ns-top" property to value .

Controls if writting this documentsshould use namespaces declaration at root GXmlElement.

This removes full declaration at childs nodes, because they are just prefixed if a prefix was defined for namespace apply.

Parameters

self

the GXmlDocument instance to modify

 

value

the new value of the "ns-top" property

 

gxml_document_get_prefix_default_ns ()

gboolean
gxml_document_get_prefix_default_ns (GXmlDocument *self);

Get and return the current value of the "prefix-default-ns" property.

Controls if writting this document should use default namespace's prefix to prefix root's childs GXmlElement.

This removes prefix on childs using default namespace. Default namespace is the first one found in "namespaces" for this document.

Parameters

self

the GXmlDocument instance to query

 

Returns

the value of the "prefix-default-ns" property


gxml_document_set_prefix_default_ns ()

void
gxml_document_set_prefix_default_ns (GXmlDocument *self,
                                     gboolean value);

Set the value of the "prefix-default-ns" property to value .

Controls if writting this document should use default namespace's prefix to prefix root's childs GXmlElement.

This removes prefix on childs using default namespace. Default namespace is the first one found in "namespaces" for this document.

Parameters

self

the GXmlDocument instance to modify

 

value

the new value of the "prefix-default-ns" property

 

gxml_document_get_backup ()

gboolean
gxml_document_get_backup (GXmlDocument *self);

Get and return the current value of the "backup" property.

Controls if writting to a GFile creates a backup, by default is true;

Parameters

self

the GXmlDocument instance to query

 

Returns

the value of the "backup" property


gxml_document_set_backup ()

void
gxml_document_set_backup (GXmlDocument *self,
                          gboolean value);

Set the value of the "backup" property to value .

Controls if writting to a GFile creates a backup, by default is true;

Parameters

self

the GXmlDocument instance to modify

 

value

the new value of the "backup" property

 

gxml_document_get_root ()

GXmlNode *
gxml_document_get_root (GXmlDocument *self);

Get and return the current value of the "root" property.

XML document root node as a GXmlElement.

Parameters

self

the GXmlDocument instance to query

 

Returns

the value of the "root" property


gxml_document_get_file ()

GFile *
gxml_document_get_file (GXmlDocument *self);

Get and return the current value of the "file" property.

Stores a GFile to save/read XML documents to/from.

Parameters

self

the GXmlDocument instance to query

 

Returns

the value of the "file" property


gxml_document_set_file ()

void
gxml_document_set_file (GXmlDocument *self,
                        GFile *value);

Set the value of the "file" property to value .

Stores a GFile to save/read XML documents to/from.

Parameters

self

the GXmlDocument instance to modify

 

value

the new value of the "file" property

 

gxml_document_new_default ()

GXmlDocument *
gxml_document_new_default (void);

Creates a new GXmlDocument using default implementation class.

As an interface you can create your own implementation of it, but if default one is required use this.


gxml_document_new_default_for_path ()

GXmlDocument *
gxml_document_new_default_for_path (const gchar *path,
                                    GError **error);

Creates a new GXmlDocument from a file path using default implementation class.

As an interface you can create your own implementation of it, but if default one is required use this.

Parameters

path

 

 

error

location to store the error occuring, or NULL to ignore

 

gxml_document_new_default_for_file ()

GXmlDocument *
gxml_document_new_default_for_file (GFile *f,
                                    GError **error);

Creates a new GXmlDocument from a GFile using default implementation class.

As an interface you can create your own implementation of it, but if default one is required use this.

Parameters

f

 

 

error

location to store the error occuring, or NULL to ignore

 

Types and Values

enum GXmlDocumentError

Errors for documents handling reading/writing

Members

GXML_DOCUMENT_ERROR_INVALID_DOCUMENT_ERROR

   

GXML_DOCUMENT_ERROR_INVALID_FILE

   

GXmlDocument

typedef struct _GXmlDocument GXmlDocument;

Interface to handle XML documents.

Provides basic interfaces to read and create XML documents.


struct GXmlDocumentIface

struct GXmlDocumentIface {
	GTypeInterface parent_iface;
	GXmlNode* (*create_element) (GXmlDocument* self, const gchar* name, GError** error);
	GXmlNode* (*create_text) (GXmlDocument* self, const gchar* text);
	GXmlNode* (*create_comment) (GXmlDocument* self, const gchar* text);
	GXmlNode* (*create_cdata) (GXmlDocument* self, const gchar* text);
	GXmlNode* (*create_pi) (GXmlDocument* self, const gchar* target, const gchar* data);
	gboolean (*save) (GXmlDocument* self, GCancellable* cancellable, GError** error);
	gboolean (*save_as) (GXmlDocument* self, GFile* f, GCancellable* cancellable, GError** error);
	gboolean (*get_indent) (GXmlDocument* self);
	void (*set_indent) (GXmlDocument* self, gboolean value);
	gboolean (*get_ns_top) (GXmlDocument* self);
	void (*set_ns_top) (GXmlDocument* self, gboolean value);
	gboolean (*get_prefix_default_ns) (GXmlDocument* self);
	void (*set_prefix_default_ns) (GXmlDocument* self, gboolean value);
	gboolean (*get_backup) (GXmlDocument* self);
	void (*set_backup) (GXmlDocument* self, gboolean value);
	GXmlNode* (*get_root) (GXmlDocument* self);
	GFile* (*get_file) (GXmlDocument* self);
	void (*set_file) (GXmlDocument* self, GFile* value);
};

Interface for creating GXmlDocument implementations.

Members

GTypeInterface parent_iface;

the parent interface structure

 

create_element ()

virtual method called by gxml_document_create_element()

 

create_text ()

virtual method called by gxml_document_create_text()

 

create_comment ()

virtual method called by gxml_document_create_comment()

 

create_cdata ()

virtual method called by gxml_document_create_cdata()

 

create_pi ()

virtual method called by gxml_document_create_pi()

 

save ()

virtual method called by gxml_document_save()

 

save_as ()

virtual method called by gxml_document_save_as()

 

get_indent ()

getter method for the abstract property "indent"

 

set_indent ()

setter method for the abstract property "indent"

 

get_ns_top ()

getter method for the abstract property "ns-top"

 

set_ns_top ()

setter method for the abstract property "ns-top"

 

get_prefix_default_ns ()

getter method for the abstract property "prefix-default-ns"

 

set_prefix_default_ns ()

setter method for the abstract property "prefix-default-ns"

 

get_backup ()

getter method for the abstract property "backup"

 

set_backup ()

setter method for the abstract property "backup"

 

get_root ()

getter method for the abstract property "root"

 

get_file ()

getter method for the abstract property "file"

 

set_file ()

setter method for the abstract property "file"