Simple C Expat Wrapper (SCEW)  1.1.7
Files | Functions
Attributes

Handle element's attributes. More...

Files

file  element.h
 SCEW element's handling routines.
 

Functions

SCEW_API unsigned int scew_element_attribute_count (scew_element const *element)
 Returns the number of attributes of the given element. More...
 
SCEW_API scew_listscew_element_attributes (scew_element const *element)
 Returns the list of all the element's attributes. More...
 
SCEW_API scew_attributescew_element_attribute_by_name (scew_element const *element, XML_Char const *name)
 Returns the first attribute from the specified element that matches the given name. More...
 
SCEW_API scew_attributescew_element_attribute_by_index (scew_element const *element, unsigned int index)
 Returns the attribute of the given element at the specified zero-based index. More...
 
SCEW_API scew_attributescew_element_add_attribute (scew_element *element, scew_attribute *attribute)
 Adds an existent attribute to the given element. More...
 
SCEW_API scew_attributescew_element_add_attribute_pair (scew_element *element, XML_Char const *name, XML_Char const *value)
 Creates and adds a new attribute to the given element. More...
 
SCEW_API void scew_element_delete_attribute_all (scew_element *element)
 Deletes all the attributes of the given element. More...
 
SCEW_API void scew_element_delete_attribute (scew_element *element, scew_attribute *attribute)
 Deletes the given attribute from the specified element. More...
 
SCEW_API void scew_element_delete_attribute_by_name (scew_element *element, XML_Char const *name)
 Deletes the first attribute of the given element that matches name. More...
 
SCEW_API void scew_element_delete_attribute_by_index (scew_element *element, unsigned int index)
 Deletes the attribute of the given element at the specified zero-based index. More...
 

Detailed Description

Handle element's attributes.

Function Documentation

SCEW_API unsigned int scew_element_attribute_count ( scew_element const *  element)

Returns the number of attributes of the given element.

An element can have zero or more attributes.

Precondition
element != NULL
SCEW_API scew_list* scew_element_attributes ( scew_element const *  element)

Returns the list of all the element's attributes.

This is the internal list where element's attributes are stored, so no modifications or deletions should be performed on this list.

Precondition
element != NULL
Returns
the list of the given element's attributes.
SCEW_API scew_attribute* scew_element_attribute_by_name ( scew_element const *  element,
XML_Char const *  name 
)

Returns the first attribute from the specified element that matches the given name.

Remember that XML attributes are case-sensitive.

Precondition
element != NULL
name != NULL
Returns
the attribute with the given name, or NULL if not found.
SCEW_API scew_attribute* scew_element_attribute_by_index ( scew_element const *  element,
unsigned int  index 
)

Returns the attribute of the given element at the specified zero-based index.

Precondition
element != NULL
index < scew_element_attribute_count
Returns
the attribute at the specified position, or NULL if the element has not attributes.
SCEW_API scew_attribute* scew_element_add_attribute ( scew_element element,
scew_attribute attribute 
)

Adds an existent attribute to the given element.

It is important to note that the given attribute will be part of the element's attributes (ownership is lost), so it should not be later freed, and it should not be part of another attribute element list.

Also note that, if the attribute already existed, the old value will be overwritten and the given attribute will not become part of the element's attribute list (only the old value is updated).

Precondition
element != NULL
attribute != NULL
Returns
the new attribute added to the element, or NULL if the attribute could not be added or updated.
SCEW_API scew_attribute* scew_element_add_attribute_pair ( scew_element element,
XML_Char const *  name,
XML_Char const *  value 
)

Creates and adds a new attribute to the given element.

An attribute is formed by a pair (name, value).

If the attribute already existed, the old value will be overwritten, thus the new attribute will not be created (only the old value is updated).

Precondition
element != NULL
name != NULL
value != NULL
Returns
the new attribute added to the element, or NULL if the attribute could not be added or updated.
SCEW_API void scew_element_delete_attribute_all ( scew_element element)

Deletes all the attributes of the given element.

This will also automatically free all the attributes.

Precondition
element != NULL
SCEW_API void scew_element_delete_attribute ( scew_element element,
scew_attribute attribute 
)

Deletes the given attribute from the specified element.

This will also automatically free the given attribute.

Precondition
element != NULL
attribute != NULL
SCEW_API void scew_element_delete_attribute_by_name ( scew_element element,
XML_Char const *  name 
)

Deletes the first attribute of the given element that matches name.

This will also automatically free the attribute.

Precondition
element != NULL
name != NULL
SCEW_API void scew_element_delete_attribute_by_index ( scew_element element,
unsigned int  index 
)

Deletes the attribute of the given element at the specified zero-based index.

This will also automatically free the attribute.

Precondition
element != NULL
index < scew_element_attribute_count