Main Page | File List | File Members

element.h File Reference

SCEW element type declaration. More...

#include "types.h"
#include <expat.h>

Go to the source code of this file.

Functions

scew_elementscew_element_create (XML_Char const *name)
void scew_element_free (scew_element *element)
unsigned int scew_element_count (scew_element const *element)
scew_elementscew_element_next (scew_element const *parent, scew_element const *element)
scew_elementscew_element_by_index (scew_element *parent, unsigned int idx)
scew_elementscew_element_by_name (scew_element const *parent, XML_Char const *name)
scew_element ** scew_element_list (scew_element const *parent, XML_Char const *name, unsigned int *count)
void scew_element_list_free (scew_element **lst)
XML_Char const * scew_element_name (scew_element const *element)
XML_Char const * scew_element_contents (scew_element const *element)
XML_Char const * scew_element_set_name (scew_element *element, XML_Char const *name)
XML_Char const * scew_element_set_contents (scew_element *element, XML_Char const *data)
scew_elementscew_element_add (scew_element *element, XML_Char const *name)
scew_elementscew_element_add_elem (scew_element *element, scew_element *new_elem)
void scew_element_del (scew_element *element)
void scew_element_del_by_name (scew_element *element, XML_Char const *name)
void scew_element_del_by_index (scew_element *element, unsigned int idx)
void scew_element_list_del (scew_element *element, XML_Char const *name)
scew_attributescew_element_add_attr (scew_element *element, scew_attribute *attribute)
scew_attributescew_element_add_attr_pair (scew_element *element, XML_Char const *name, XML_Char const *value)
void scew_element_del_attr (scew_element *element, XML_Char const *name)


Detailed Description

SCEW element type declaration.

Author:
Aleix Conchillo Flaque <aleix@member.fsf.org>
Date:
Mon Nov 25, 2002 00:48
Id
element.h,v 1.4 2004/03/08 22:46:04 aleix Exp

Element related functions. SCEW provides functions to access and manipulate the elements of an XML tree.


Function Documentation

scew_element* scew_element_create XML_Char const *  name  ) 
 

Creates a new element with the given name. This element is not yet related to any XML tree.

void scew_element_free scew_element element  ) 
 

Frees an element recursively. That is, it frees all his childs and attributes.

unsigned int scew_element_count scew_element const *  element  ) 
 

Returns the number of children of the specified element. An element can have zero or more children.

scew_element* scew_element_next scew_element const *  parent,
scew_element const *  element
 

Returns the parent's child element if element is NULL, otherwise it returns the contiguous element to the given one.

Call this function a first time with element to NULL and a parent's child element will be returned. In the subsequent calls you just need to provide the element returned and its sibling will be returned.

Returns:
a parent's child element or a contiguous element. NULL if there are no more elements.

scew_element* scew_element_by_index scew_element parent,
unsigned int  idx
 

Returns the child element on the specified position. Positions are zero based.

Note: Do not call this function if you just want to iterate through the elements, because you would have a serious performance degradation in large documents. Use scew_element_next instead.

This function is for element random access.

See also:
scew_element_next
Returns:
the element on the specified position, NULL if there is no element in the position.

scew_element* scew_element_by_name scew_element const *  parent,
XML_Char const *  name
 

Returns the first element child that matches the given name. Remember that XML names are case-sensitive.

Returns:
the first element that matches the given name, NULL if not found.

scew_element** scew_element_list scew_element const *  parent,
XML_Char const *  name,
unsigned int *  count
 

Returns a list of elements that matches the name specified. The number of elements is returned in count. The returned pointer must be freed after using it, calling the scew_element_list_free function.

void scew_element_list_free scew_element **  lst  ) 
 

Frees an element list created by scew_element_list.

XML_Char const* scew_element_name scew_element const *  element  ) 
 

Returns the element name or NULL if the element does not exist.

XML_Char const* scew_element_contents scew_element const *  element  ) 
 

Returns the element contents value. That is the contents between the start and end element tags. Returns NULL if element has no contents.

XML_Char const* scew_element_set_name scew_element element,
XML_Char const *  name
 

Sets a new name to the given element and frees the old one.

Returns:
the new element name.

XML_Char const* scew_element_set_contents scew_element element,
XML_Char const *  data
 

Sets the new contents to the given element and frees the old one.

Returns:
the new element's contents.

scew_element* scew_element_add scew_element element,
XML_Char const *  name
 

Adds a new child to the given element with the specified name.

Returns:
the new element created.

scew_element* scew_element_add_elem scew_element element,
scew_element new_elem
 

Adds an already existent element (new_elem) as a child of the given element (element). Note that the element being added should be a clean element, that is, an element created with scew_element_create, and not an element from another XML tree.

See also:
scew_element_create
Returns:
the element added.

void scew_element_del scew_element element  ) 
 

This function is equivalent to scew_element_free.

See also:
scew_element_free

void scew_element_del_by_name scew_element element,
XML_Char const *  name
 

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

void scew_element_del_by_index scew_element element,
unsigned int  idx
 

Deletes the child element at the specified position.

void scew_element_list_del scew_element element,
XML_Char const *  name
 

Deletes all child elements of the given element that match name. This function will get an element list created by scew_element_list and will free all the elements in it. Note that this function is not equivalent to scew_element_list_free.

See also:
scew_element_list

scew_attribute* scew_element_add_attr scew_element element,
scew_attribute attribute
 

Adds an already created attribute to the element. If the attribute already exist, the old value will be overwritten. It is important to note that the attribute given will be part of the element's attributes (ownership is lost), so it should not be freed, and it should not be part of another attribute element list.

See also:
attribute.h
Returns:
the new attribute added to the element.

scew_attribute* scew_element_add_attr_pair scew_element element,
XML_Char const *  name,
XML_Char const *  value
 

Adds a new attribute to the given element. An attribute is formed by a pair (name, value). If the attribute already exist, the old value will be overwritten.

See also:
attribute.h
Returns:
the new attribute added to the element.

void scew_element_del_attr scew_element element,
XML_Char const *  name
 

Deletes an attribute from an element.


Generated on Tue May 25 23:38:29 2004 for Simple C Expat Wrapper by doxygen 1.3.7