GXmlxDocument

GXmlxDocument — Represents an XML xDocument as a tree of GXmlxNodes.

Functions

Types and Values

Description

The xDocument has a root document element GXmlxElement. A xDocument's schema can be defined through its GXmlxDocumentType.

Version: DOM Level 1 Core

URL: http://www.w3.org/TR/DOM-Level-1/level-one-core.html#i-xDocument

Functions

gxml_xdocument_save_to_path ()

void
gxml_xdocument_save_to_path (GXmlxDocument *self,
                             const gchar *file_path,
                             GError **error);

Saves a xDocument to the file at path file_path

GXmlError will be returned in error

A GXmlError if an error occurs while writing

Parameters

self

the GXmlxDocument instance

 

file_path

 .

A path on the local system to save the document to

.

[in]

error

location to store the error occuring, or NULL to ignore.

[error-domains GXmlError]

gxml_xdocument_save_to_stream ()

void
gxml_xdocument_save_to_stream (GXmlxDocument *self,
                               GOutputStream *outstream,
                               GCancellable *can,
                               GError **error);

Saves a xDocument to the OutputStream outstream.

GXmlError will be returned in error

A GXmlError is thrown if saving encounters an error

Parameters

self

the GXmlxDocument instance

 

outstream

 .

A destination GOutputStream to save the XML file to

.

[in]

can

 .

A GCancellable to cancel saving with, or NULL

.

[in][allow-none]

error

location to store the error occuring, or NULL to ignore

 

gxml_xdocument_create_document_fragment ()

GXmlDocumentFragment *
gxml_xdocument_create_document_fragment
                               (GXmlxDocument *self);

Creates a GXmlDocumentFragment.

xDocument fragments do not can contain a subset of a document, without being a complete tree. Its memory is freed when its owner document is freed.

Version: DOM Level 1 Core

URL: http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createDocumentFragment

Parameters

self

the GXmlxDocument instance

 

Returns

A GXmlDocumentFragment; this should not be freed


gxml_xdocument_create_text_node ()

GXmlxText *
gxml_xdocument_create_text_node (GXmlxDocument *self,
                                 const gchar *text_data);

Creates a GXmlText node containing the text in data. Its memory is freed when its owner document is freed.

XML example:

<someElement>Text is contained here.</someElement>

Version: DOM Level 1 Core

URL: http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createTextNode

Parameters

self

the GXmlxDocument instance

 

text_data

 .

The textual data for the GXmlText node

.

[in]

Returns

A new GXmlText node containing the supplied data; this should not be freed


gxml_xdocument_create_managed_comment ()

GXmlxComment *
gxml_xdocument_create_managed_comment (GXmlxDocument *self,
                                       const gchar *comment_data);

Creates an XML comment with data. Its memory is freed when its owner document is freed.

XML example:

 <!-- data -->

Version: DOM Level 1 Core

URL: http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createComment

Parameters

self

the GXmlxDocument instance

 

comment_data

 .

The content of the comment

.

[in]

Returns

A new GXmlComment containing the supplied data; this should not be freed


gxml_xdocument_create_cdata_section ()

GXmlxCDATASection *
gxml_xdocument_create_cdata_section (GXmlxDocument *self,
                                     const gchar *cdata_data);

Creates a CDATA section containing data.

These do not apply to HTML doctype documents. Its memory is freed when its owner document is freed.

XML example:

 <![CDATA[Here contains non-XML data, like code, or something that requires a lot of special XML entities.]]>. 

Version: DOM Level 1 Core

URL: http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createCDATASection

Parameters

self

the GXmlxDocument instance

 

cdata_data

 .

The content for the CDATA section

.

[in]

Returns

A new GXmlxCDATASection with the supplied data; this should not be freed


gxml_xdocument_create_processing_instruction ()

GXmlxProcessingInstruction *
gxml_xdocument_create_processing_instruction
                               (GXmlxDocument *self,
                                const gchar *target,
                                const gchar *data);

Creates a new GXmlProcessingInstruction.

Its memory is freed when its owner document is freed.

Version: DOM Level 1 Core

URL: http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createProcessingInstruction

Parameters

self

the GXmlxDocument instance

 

target

 .

The target of the instruction

.

[in]

data

 .

The content of the instruction

.

[in]

Returns

A new GXmlProcessingInstruction for the given target; this should not be freed


gxml_xdocument_create_attribute ()

GXmlxAttr *
gxml_xdocument_create_attribute (GXmlxDocument *self,
                                 const gchar *name);

Creates an GXmlAttribute attribute with name, usually to be associated with an xElement.

XML example:

<element attributename="attributevalue">content</element>

Version: DOM Level 1 Core

URL: http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createAttribute

Parameters

self

the GXmlxDocument instance

 

name

 .

The name of the attribute

.

[in]

Returns

A new GXmlAttribute with the given `name`; this should not be freed


gxml_xdocument_create_entity_reference ()

GXmlEntityReference *
gxml_xdocument_create_entity_reference
                               (GXmlxDocument *self,
                                const gchar *name);

Creates an entity reference.

XML example:

&name;

, for example an apostrophe has the name 'apos', so in XML it appears as

&apos;

Version: DOM Level 1 Core

URL: http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createEntityReference

Parameters

self

the GXmlxDocument instance

 

name

 .

The 'name' of the entity reference

.

[in]

Returns

An GXmlEntityReference for `name`; this should not be freed


gxml_xdocument_get_elements_by_tag_name ()

GXmlxNodeList *
gxml_xdocument_get_elements_by_tag_name
                               (GXmlxDocument *self,
                                const gchar *tag_name);

Obtains a list of GXmlxElements, each with the given tag name tag_name, contained within this document.

Note that the list is live, updated as new elements are added to the document.

Unlike a GXmlxNode and its subclasses, GXmlNodeList are not part of the document tree, and thus their memory is not managed for the user, so the user must explicitly free them.

Version: DOM Level 1 Core

URL: http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-getElementsByTagName

Parameters

self

the GXmlxDocument instance

 

tag_name

 .

The GXmlxElement tag name we matching for

.

[in]

Returns

A GXmlNodeList of GXmlxElements; this must be freed with g_object_unref().


gxml_xdocument_copy_node ()

GXmlxNode *
gxml_xdocument_copy_node (GXmlxDocument *self,
                          GXmlxNode *foreign_node,
                          gboolean deep);

Parameters

self

the GXmlxDocument instance

 

foreign_node

 

 

deep

 

 

gxml_xdocument_new_from_libxml2 ()

GXmlxDocument *
gxml_xdocument_new_from_libxml2 (xmlDoc *doc,
                                 gboolean require_root);

Creates a xDocument based on a libxml2 Xml.Doc* object.

Parameters

doc

 .

A xmlDoc from libxml2

.

[in]

require_root

 .

A flag to indicate whether we should require a root node, which the DOM normally expects

.

[in]

Returns

A new GXmlxDocument wrapping the provided xmlDoc; this must be freed with g_object_unref()


gxml_xdocument_new_from_path ()

GXmlxDocument *
gxml_xdocument_new_from_path (const gchar *file_path,
                              GError **error);

Creates a xDocument from the file at file_path.

GXmlError will be returned in error

A GXmlError if an error occurs while loading

Parameters

file_path

 .

A path to an XML document

.

[in]

error

location to store the error occuring, or NULL to ignore.

[error-domains GXmlError]

Returns

A GXmlxDocument for the given `file_path`; this must be freed with g_object_unref()


gxml_xdocument_new_from_gfile ()

GXmlxDocument *
gxml_xdocument_new_from_gfile (GFile *fin,
                               GCancellable *can,
                               GError **error);

Creates a xDocument for the GFile fin.

GError will be returned in error

A GError if an error cocurs while reading the GFile

GXmlError will be returned in error

A GXmlError if an error occurs while reading the file as a stream

Parameters

fin

 .

The GFile containing the document

.

[in]

can

 .

A GCancellable to let you cancel opening the file, or NULL

.

[in][allow-none]

error

location to store the error occuring, or NULL to ignore.

[error-domains GXmlError]

Returns

A new GXmlxDocument for `fin`; this must be freed with g_object_unref()


gxml_xdocument_new_from_stream ()

GXmlxDocument *
gxml_xdocument_new_from_stream (GInputStream *instream,
                                GCancellable *can,
                                GError **error);

Creates a GXmlxDocument from data provided through a GInputStream.

GXmlError will be returned in error

A GXmlError if an error occurs while reading the stream

Parameters

instream

 .

A GInputStream providing our document

.

[in]

can

 .

A GCancellable object allowing the caller to interrupt and cancel this operation, or NULL

.

[in][allow-none]

error

location to store the error occuring, or NULL to ignore

 

Returns

A new GXmlxDocument built from the contents of instream; this must be freed with g_object_unref()


gxml_xdocument_new_from_string ()

GXmlxDocument *
gxml_xdocument_new_from_string (const gchar *xml);

Creates a xDocument from data found in memory.

Parameters

xml

 .

A string representing an XML document

.

[in]

Returns

A new GXmlxDocument from `memory`; this must be freed with g_object_unref()


gxml_xdocument_new_from_string_with_options ()

GXmlxDocument *
gxml_xdocument_new_from_string_with_options
                               (const gchar *xml,
                                const gchar *url,
                                const gchar *encoding,
                                gint options,
                                GError **error);

Creates a xDocument from data found in memory using options.

Parameters

xml

 .

A string representing an XML document

.

[in]

url

 .

the base URL to use for the document

.

[in][allow-none]

encoding

 .

the document encoding

.

[in][allow-none]

options

 .

a combination of xmlParserOption

.

[in]

error

location to store the error occuring, or NULL to ignore

 

Returns

A new GXmlxDocument from `memory`; this must be freed with g_object_unref()


gxml_xdocument_new ()

GXmlxDocument *
gxml_xdocument_new (void);

Creates an empty document.

Returns

A new, empty GXmlxDocument; this must be freed with g_object_unref()


gxml_xdocument_get_doctype ()

GXmlxDocumentType *
gxml_xdocument_get_doctype (GXmlxDocument *self);

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

The xDocument Type Definition (DTD) defining this document. This may be NULL.

Version: DOM Level 1 Core URL: http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-doctype

Parameters

self

the GXmlxDocument instance to query

 

Returns

the value of the "doctype" property


gxml_xdocument_get_implementation ()

GXmlImplementation *
gxml_xdocument_get_implementation (GXmlxDocument *self);

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

Describes the features of the DOM implementation behind this document.

Version: DOM Level 1 Core URL: http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-implementation

Parameters

self

the GXmlxDocument instance to query

 

Returns

the value of the "implementation" property


gxml_xdocument_get_document_element ()

GXmlxElement *
gxml_xdocument_get_document_element (GXmlxDocument *self);

Get and return the current value of the "document-element" property.

The root node of the document's node tree.

Version: DOM Level 1 Core URL: http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-documentElement

Parameters

self

the GXmlxDocument instance to query

 

Returns

the value of the "document-element" property


gxml_xdocument_get_root ()

GXmlNode *
gxml_xdocument_get_root (GXmlxDocument *self);

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

Parameters

self

the GXmlxDocument instance to query

 

Returns

the value of the "root" property

Types and Values

GXML_TYPE_XDOCUMENT

#define GXML_TYPE_XDOCUMENT (gxml_xdocument_get_type ())

The type for GXmlxDocument.


struct GXmlxDocument

struct GXmlxDocument {
	GXmlxNode parent_instance;
	GXmlxDocumentPrivate * priv;
	GHashTable* node_dict;
	GList* dirty_elements;
	xmlDoc* xmldoc;
	GXmlNodeChildNodeList* _node_list;
};

Represents an XML xDocument as a tree of GXmlxNodes.

The xDocument has a root document element GXmlxElement. A xDocument's schema can be defined through its GXmlxDocumentType.

Version: DOM Level 1 Core

URL: http://www.w3.org/TR/DOM-Level-1/level-one-core.html#i-xDocument


struct GXmlxDocumentClass

struct GXmlxDocumentClass {
	GXmlxNodeClass parent_class;
	GXmlNode* (*get_root) (GXmlxDocument* self);
};

The class structure for GXML_TYPE_XDOCUMENT. All the fields in this structure are private and should never be accessed directly.

Members

get_root ()

getter method for the abstract property "root"