openldev/openldev-settings/openldev-xml-parser.h File Reference

OpenLDevXmlDocument. More...

#include <gtk/gtk.h>
#include <string>
#include <vector>
#include <libxml/tree.h>
#include <libxml/xmlreader.h>

Data Structures

struct  OpenLDevXmlDocument
 An XML document structure and the path to the xml file. More...

Functions

OpenLDevXmlDocumentopenldev_xml_document_new (const string &xml_file)
OpenLDevXmlDocumentopenldev_xml_document_open (const string &xml_file)
void openldev_xml_document_save (OpenLDevXmlDocument **xml_document)
void openldev_xml_document_close (OpenLDevXmlDocument **xml_document)
void openldev_xml_document_change_filename (OpenLDevXmlDocument *xml_document, const string &new_filename)
void openldev_xml_document_set_root_element (OpenLDevXmlDocument *xml_document, const string &element_name)
void openldev_xml_document_set_root_attribute (OpenLDevXmlDocument *xml_document, const string &attribute_name, const string &value)
void openldev_xml_document_remove_root_attribute (OpenLDevXmlDocument *xml_document, const string &attribute_name)
gboolean openldev_xml_document_set_element (OpenLDevXmlDocument *xml_document, const string &element_name, const string &value)
gboolean openldev_xml_document_add_element (OpenLDevXmlDocument *xml_document, const string &element_name, const string &value)
gboolean openldev_xml_document_set_attribute (OpenLDevXmlDocument *xml_document, const string &parent_name, const string &element_name, const string &attribute_name, const string &value)
string openldev_xml_document_element_value (OpenLDevXmlDocument *xml_document, const string &element_name)
vector< string > openldev_xml_document_element_values (OpenLDevXmlDocument *xml_document, const string &element_name)
string openldev_xml_document_attribute_value (OpenLDevXmlDocument *xml_document, const string &parent_name, const string &element_name, const string &attribute_name)
string openldev_xml_document_root_attribute (OpenLDevXmlDocument *xml_document, const string &attribute_name)
void openldev_xml_document_remove_element (OpenLDevXmlDocument *xml_document, const string &element_name, const string &value)
void openldev_xml_document_remove_children (OpenLDevXmlDocument *xml_document, const string &parent_element)
void openldev_xml_document_remove_attribute (OpenLDevXmlDocument *xml_document, const string &parent_name, const string &element_name, const string &attribute_name)


Detailed Description


Function Documentation

gboolean openldev_xml_document_add_element OpenLDevXmlDocument xml_document,
const string &  element_name,
const string &  value
 

Add new element as child to parent element. Use this function to add multiple elements with same name. Functions fails if parent element was not found.

Parameters:
xml_document Pointer to the xml document object
parent_name Name of the parent element
element_name Name of the element
value Value of the element
Returns:
True if element was added, otherwise false

string openldev_xml_document_attribute_value OpenLDevXmlDocument xml_document,
const string &  parent_name,
const string &  element_name,
const string &  attribute_name
 

Return the value of an attribute from an element.

Parameters:
xml_document Pointer to the xml document object
element_name Name of the element
attribute_name Name of the attribute
Returns:
The value of the attribute, or an empty string if attribute was not found

void openldev_xml_document_change_filename OpenLDevXmlDocument xml_document,
const string &  new_filename
 

Change the name under which the xml file will be saved.

Parameters:
xml_document The xml document
new_filename New file name (with path)

void openldev_xml_document_close OpenLDevXmlDocument **  xml_document  ) 
 

Close a previously opened xml document. The xml document will be freed, and the xml document pointer is set to NULL.

Parameters:
xml_document Address of pointer to the xml document

string openldev_xml_document_element_value OpenLDevXmlDocument xml_document,
const string &  element_name
 

Return an elements value.

Parameters:
xml_document Pointer to the xml document object
parent_name Name of the parent element
element_name Name of the element
Returns:
The value of the element, or an empty string if element was not found

vector<string> openldev_xml_document_element_values OpenLDevXmlDocument xml_document,
const string &  element_name
 

Return a list of values of all elements named element_name.

Parameters:
xml_document Pointer to the xml document object
parent_name Name of the parent element
element_name Name of the element
Returns:
A list of values, or an empty list if no element was found

OpenLDevXmlDocument* openldev_xml_document_new const string &  xml_file  ) 
 

Create a new xml document with parameter xml_file where to save it.

Parameters:
xml_file Filename of the new xml file
Returns:
Pointer to an xml document object, NULL if failure occured

OpenLDevXmlDocument* openldev_xml_document_open const string &  xml_file  ) 
 

Open an existing xml document from path to xml_file.

Parameters:
xml_file Name (with path) of the xml file
Returns:
Pointer to an xml document object, NULL if failure occured

void openldev_xml_document_remove_attribute OpenLDevXmlDocument xml_document,
const string &  parent_name,
const string &  element_name,
const string &  attribute_name
 

Remove an attribute from an element.

Parameters:
xml_document Pointer to the xml document object
element_name Name of the element
attribute_name Name of the attribute

void openldev_xml_document_remove_children OpenLDevXmlDocument xml_document,
const string &  parent_element
 

Remove all children from parent element.

Parameters:
xml_document Pointer to the xml document object
parent_element Name of the parent element

void openldev_xml_document_remove_element OpenLDevXmlDocument xml_document,
const string &  element_name,
const string &  value
 

Remove a child element with given value from parent element. If the parameter value is empty all elements with given name will be removed.

Parameters:
xml_document Pointer to the xml document object
parent_element Name of the parent element
element_name Name of the element
value The value of the element to remove, or empty to remove all elements

void openldev_xml_document_remove_root_attribute OpenLDevXmlDocument xml_document,
const string &  attribute_name
 

Remove an attribute from the root element.

Parameters:
xml_document Pointer to the xml document object
attribute_name Name of the attribute

string openldev_xml_document_root_attribute OpenLDevXmlDocument xml_document,
const string &  attribute_name
 

Return the value of an attribute from an element.

Parameters:
xml_document Pointer to the xml document object
attribute_name Name of the attribute
Returns:
The value of the attribute, or an empty string if attribute was not found

void openldev_xml_document_save OpenLDevXmlDocument **  xml_document  ) 
 

Save the opened xml document.

Parameters:
xml_document Address of pointer to the xml document

gboolean openldev_xml_document_set_attribute OpenLDevXmlDocument xml_document,
const string &  parent_name,
const string &  element_name,
const string &  attribute_name,
const string &  value
 

Set an attribute with value. If attribute is missing it will be created. Function fails if either the parent element or the element could not be found.

Parameters:
xml_document Pointer to the xml document object
parent_name Name of the parent element
element_name Name of the element
attribute_name Name of the attribute
value New value of the attribute
Returns:
True if value is set, otherwise false

gboolean openldev_xml_document_set_element OpenLDevXmlDocument xml_document,
const string &  element_name,
const string &  value
 

Set an element with value as child to parent element. If element exists, it will be replaced. Function fails if either the parent element or the element could not be found.

Parameters:
xml_document Pointer to the xml document object
parent_name Name of the parent element
element_name Name of the element
value Value of the element
Returns:
True if element was set, otherwise false

void openldev_xml_document_set_root_attribute OpenLDevXmlDocument xml_document,
const string &  attribute_name,
const string &  value
 

Set an attribute in the root element. Value will be changed if attribute exists.

Parameters:
xml_document Pointer to the xml document object
attribute_name Name of the attribute
value Value of the attribute

void openldev_xml_document_set_root_element OpenLDevXmlDocument xml_document,
const string &  element_name
 

Set a new root element. The old structure of the xml document will be lost.

Parameters:
xml_document Pointer to the xml document object
element_name Name of the new root element


Generated on Sun May 14 14:57:41 2006 for OpenLDev by  doxygen 1.4.6