GXmlxElement

GXmlxElement — Represent an XML xElement node, which have attributes and children.

Functions

Types and Values

Description

To create one, use gxml_xdocument_create_element().

These can have child nodes of various types including other Elements. Elements can have Attr attributes associated with them. Elements have tag names. In addition to methods inherited from Node, Elements have additional methods for manipulating attributes, as an alternative to manipulating the attributes HashMap directly.

Version: DOM Level 1 Core

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

Functions

gxml_xelement_get_attribute ()

gchar *
gxml_xelement_get_attribute (GXmlxElement *self,
                             const gchar *name);

Retrieve the attribute value, as a string, for an attribute associated with this element with the name name.

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

Parameters

self

the GXmlxElement instance

 

name

 .

The name of the attribute whose value to retrieve

.

[in]

Returns

The value of the named attribute, or "" if no such attribute is set.


gxml_xelement_set_attribute ()

void
gxml_xelement_set_attribute (GXmlxElement *self,
                             const gchar *name,
                             const gchar *value);

Set the value of this element's attribute named name to the string value.

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

Parameters

self

the GXmlxElement instance

 

name

 .

Name of the attribute whose value to set

.

[in]

value

 .

The value to set

.

[in]

gxml_xelement_remove_attribute ()

void
gxml_xelement_remove_attribute (GXmlxElement *self,
                                const gchar *name);

Remove the attribute named name from this element.

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

Parameters

self

the GXmlxElement instance

 

name

 .

The name of the attribute to unset

.

[in]

gxml_xelement_get_attribute_node ()

GXmlxAttr *
gxml_xelement_get_attribute_node (GXmlxElement *self,
                                  const gchar *name);

Get the Attr node representing this element's attribute named name.

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

Parameters

self

the GXmlxElement instance

 

name

 .

The name of the Attr node to retrieve

.

[in]

Returns

The Attr node named by name for this element, or NULL if none is set


gxml_xelement_set_attribute_node ()

GXmlxAttr *
gxml_xelement_set_attribute_node (GXmlxElement *self,
                                  GXmlxAttr *new_attr);

Set the attribute in Attr for this element.

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

Parameters

self

the GXmlxElement instance

 

new_attr

 .

The attribute to set

.

[in]

Returns

If an Attr with the same name exists, it is replaced and the old Attr is returned. Elsewise, NULL is returned.


gxml_xelement_remove_attribute_node ()

GXmlxAttr *
gxml_xelement_remove_attribute_node (GXmlxElement *self,
                                     GXmlxAttr *old_attr);

Remove Attr old_attr from this element, if it was set.

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

Parameters

self

the GXmlxElement instance

 

old_attr

 .

The Attr we are removing

.

[in]

Returns

The old_attr we wanted to remove, even if it wasn't found.


gxml_xelement_get_elements_by_tag_name ()

GXmlxNodeList *
gxml_xelement_get_elements_by_tag_name
                               (GXmlxElement *self,
                                const gchar *tag_name);

Obtains a NodeList of Elements with the given tag_name that are descendants of this xElement. This will include the current element if it matches. The returned list is updated as necessary as the tree changes.

Visual explanation of get_elements_by_tag_name tree traversal.

a
 b    c
d e  f g

we want: a b d e c f g

start:
add a

pop top of stack (a)
a: check for match: yes? add to return list
a: add children from last to first (c,b) to top of stack (so head=b, then c)

a
a< [bc]
b< [de]c
d< ec
e< c
c< [fg]
f< g
g<

see a, add a, visit a

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

Parameters

self

the GXmlxElement instance

 

tag_name

 .

The tag name to match for

.

[in]

Returns

A NodeList containing the matching descendants

Types and Values

GXML_TYPE_XELEMENT

#define GXML_TYPE_XELEMENT (gxml_xelement_get_type ())

The type for GXmlxElement.


struct GXmlxElement

struct GXmlxElement {
	GXmlBackedNode parent_instance;
	GXmlxElementPrivate * priv;
};

Represent an XML xElement node, which have attributes and children.

To create one, use gxml_xdocument_create_element().

These can have child nodes of various types including other Elements. Elements can have Attr attributes associated with them. Elements have tag names. In addition to methods inherited from Node, Elements have additional methods for manipulating attributes, as an alternative to manipulating the attributes HashMap directly.

Version: DOM Level 1 Core

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


struct GXmlxElementClass

struct GXmlxElementClass {
	GXmlBackedNodeClass parent_class;
};

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

Members