xmlnode.h
Go to the documentation of this file.
/* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef _PURPLE_XMLNODE_H_
#define _PURPLE_XMLNODE_H_
#include <glib.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum _XMLNodeType
{
XMLNODE_TYPE_TAG,
XMLNODE_TYPE_ATTRIB,
XMLNODE_TYPE_DATA
} XMLNodeType;
typedef struct _xmlnode xmlnode;
struct _xmlnode
{
char *name;
char *xmlns;
XMLNodeType type;
char *data;
size_t data_sz;
xmlnode *parent;
xmlnode *child;
xmlnode *lastchild;
xmlnode *next;
char *prefix;
GHashTable *namespace_map;
};
xmlnode *xmlnode_new(const char *name);
xmlnode *xmlnode_new_child(xmlnode *parent, const char *name);
void xmlnode_insert_child(xmlnode *parent, xmlnode *child);
xmlnode *xmlnode_get_child(const xmlnode *parent, const char *name);
xmlnode *xmlnode_get_child_with_namespace(const xmlnode *parent, const char *name, const char *xmlns);
xmlnode *xmlnode_get_next_twin(xmlnode *node);
void xmlnode_insert_data(xmlnode *node, const char *data, gssize size);
char *xmlnode_get_data(const xmlnode *node);
char *xmlnode_get_data_unescaped(const xmlnode *node);
void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value);
#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_XMLNODE_C_)
void xmlnode_set_attrib_with_prefix(xmlnode *node, const char *attr, const char *prefix, const char *value);
void xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, const char *value);
#endif /* PURPLE_DISABLE_DEPRECATED */
void xmlnode_set_attrib_full(xmlnode *node, const char *attr, const char *xmlns,
const char *prefix, const char *value);
const char *xmlnode_get_attrib(const xmlnode *node, const char *attr);
const char *xmlnode_get_attrib_with_namespace(const xmlnode *node, const char *attr, const char *xmlns);
void xmlnode_remove_attrib(xmlnode *node, const char *attr);
void xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns);
void xmlnode_set_namespace(xmlnode *node, const char *xmlns);
const char *xmlnode_get_namespace(xmlnode *node);
void xmlnode_set_prefix(xmlnode *node, const char *prefix);
const char *xmlnode_get_prefix(const xmlnode *node);
xmlnode *xmlnode_get_parent(const xmlnode *child);
char *xmlnode_to_str(const xmlnode *node, int *len);
char *xmlnode_to_formatted_str(const xmlnode *node, int *len);
xmlnode *xmlnode_from_str(const char *str, gssize size);
xmlnode *xmlnode_copy(const xmlnode *src);
void xmlnode_free(xmlnode *node);
xmlnode *xmlnode_from_file(const char *dir, const char *filename,
const char *description, const char *process);
#ifdef __cplusplus
}
#endif
#endif /* _PURPLE_XMLNODE_H_ */
_xmlnode
Definition: xmlnode.h:50
_xmlnode::parent
xmlnode * parent
The parent node or NULL.
Definition: xmlnode.h:56
_xmlnode::child
xmlnode * child
The child node or NULL.
Definition: xmlnode.h:57
_xmlnode::lastchild
xmlnode * lastchild
The last child node or NULL.
Definition: xmlnode.h:58
_xmlnode::next
xmlnode * next
The next node or NULL.
Definition: xmlnode.h:59
_xmlnode::type
XMLNodeType type
The type of the node.
Definition: xmlnode.h:53
_xmlnode::data_sz
size_t data_sz
The size of the data.
Definition: xmlnode.h:55
_xmlnode::xmlns
char * xmlns
The namespace of the node.
Definition: xmlnode.h:52
_xmlnode::name
char * name
The name of the node.
Definition: xmlnode.h:51
_xmlnode::data
char * data
The data for the node.
Definition: xmlnode.h:54
_xmlnode::namespace_map
GHashTable * namespace_map
The namespace map.
Definition: xmlnode.h:61
_xmlnode::prefix
char * prefix
The namespace prefix if any.
Definition: xmlnode.h:60
xmlnode_get_data
char * xmlnode_get_data(const xmlnode *node)
Gets (escaped) data from a node.
xmlnode_get_data_unescaped
char * xmlnode_get_data_unescaped(const xmlnode *node)
Gets unescaped data from a node.
xmlnode_get_attrib
const char * xmlnode_get_attrib(const xmlnode *node, const char *attr)
Gets an attribute from a node.
xmlnode_insert_child
void xmlnode_insert_child(xmlnode *parent, xmlnode *child)
Inserts a node into a node as a child.
xmlnode_set_attrib_with_prefix
void xmlnode_set_attrib_with_prefix(xmlnode *node, const char *attr, const char *prefix, const char *value)
Sets a prefixed attribute for a node.
xmlnode_get_child
xmlnode * xmlnode_get_child(const xmlnode *parent, const char *name)
Gets a child node named name.
xmlnode_from_str
xmlnode * xmlnode_from_str(const char *str, gssize size)
Creates a node from a string of XML.
xmlnode_set_attrib_with_namespace
void xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, const char *value)
Sets a namespaced attribute for a node.
xmlnode_set_prefix
void xmlnode_set_prefix(xmlnode *node, const char *prefix)
Sets the prefix of a node.
xmlnode_get_parent
xmlnode * xmlnode_get_parent(const xmlnode *child)
Gets the parent node.
xmlnode_get_attrib_with_namespace
const char * xmlnode_get_attrib_with_namespace(const xmlnode *node, const char *attr, const char *xmlns)
Gets a namespaced attribute from a node.
xmlnode_from_file
xmlnode * xmlnode_from_file(const char *dir, const char *filename, const char *description, const char *process)
Creates a node from a XML File.
xmlnode_insert_data
void xmlnode_insert_data(xmlnode *node, const char *data, gssize size)
Inserts data into a node.
xmlnode_get_namespace
const char * xmlnode_get_namespace(xmlnode *node)
Returns the namespace of a node.
xmlnode_set_namespace
void xmlnode_set_namespace(xmlnode *node, const char *xmlns)
Sets the namespace of a node.
xmlnode_new_child
xmlnode * xmlnode_new_child(xmlnode *parent, const char *name)
Creates a new xmlnode child.
_XMLNodeType
_XMLNodeType
The valid types for an xmlnode.
Definition: xmlnode.h:39
XMLNODE_TYPE_ATTRIB
@ XMLNODE_TYPE_ATTRIB
Has attributes.
Definition: xmlnode.h:41
XMLNODE_TYPE_DATA
@ XMLNODE_TYPE_DATA
Has data.
Definition: xmlnode.h:42
XMLNODE_TYPE_TAG
@ XMLNODE_TYPE_TAG
Just a tag.
Definition: xmlnode.h:40
xmlnode_new
xmlnode * xmlnode_new(const char *name)
Creates a new xmlnode.
xmlnode_remove_attrib
void xmlnode_remove_attrib(xmlnode *node, const char *attr)
Removes an attribute from a node.
xmlnode_free
void xmlnode_free(xmlnode *node)
Frees a node and all of its children.
xmlnode_get_child_with_namespace
xmlnode * xmlnode_get_child_with_namespace(const xmlnode *parent, const char *name, const char *xmlns)
Gets a child node named name in a namespace.
xmlnode_to_formatted_str
char * xmlnode_to_formatted_str(const xmlnode *node, int *len)
Returns the node in a string of human readable xml.
xmlnode_to_str
char * xmlnode_to_str(const xmlnode *node, int *len)
Returns the node in a string of xml.
xmlnode_get_prefix
const char * xmlnode_get_prefix(const xmlnode *node)
Returns the prefix of a node.
xmlnode_remove_attrib_with_namespace
void xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns)
Removes a namespaced attribute from a node.
xmlnode_get_next_twin
xmlnode * xmlnode_get_next_twin(xmlnode *node)
Gets the next node with the same name as node.
xmlnode_set_attrib_full
void xmlnode_set_attrib_full(xmlnode *node, const char *attr, const char *xmlns, const char *prefix, const char *value)
Sets a namespaced attribute for a node.
xmlnode_set_attrib
void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value)
Sets an attribute for a node.
xmlnode_copy
xmlnode * xmlnode_copy(const xmlnode *src)
Creates a new node from the source node.
XMLNodeType
enum _XMLNodeType XMLNodeType
The valid types for an xmlnode.