pidgin 2.14.14dev
xmlnode.h
Go to the documentation of this file.
1
6/* purple
7 *
8 * Purple is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25 */
26#ifndef _PURPLE_XMLNODE_H_
27#define _PURPLE_XMLNODE_H_
28
29#include <glib.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
38typedef enum _XMLNodeType
39{
44
48typedef struct _xmlnode xmlnode;
50{
51 char *name;
52 char *xmlns;
54 char *data;
55 size_t data_sz;
60 char *prefix;
61 GHashTable *namespace_map;
62};
63
71xmlnode *xmlnode_new(const char *name);
72
81xmlnode *xmlnode_new_child(xmlnode *parent, const char *name);
82
89void xmlnode_insert_child(xmlnode *parent, xmlnode *child);
90
99xmlnode *xmlnode_get_child(const xmlnode *parent, const char *name);
100
110xmlnode *xmlnode_get_child_with_namespace(const xmlnode *parent, const char *name, const char *xmlns);
111
120
129void xmlnode_insert_data(xmlnode *node, const char *data, gssize size);
130
139char *xmlnode_get_data(const xmlnode *node);
140
150
158void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value);
159
160#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_XMLNODE_C_)
171void xmlnode_set_attrib_with_prefix(xmlnode *node, const char *attr, const char *prefix, const char *value);
172
183void xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, const char *value);
184#endif /* PURPLE_DISABLE_DEPRECATED */
185
197void xmlnode_set_attrib_full(xmlnode *node, const char *attr, const char *xmlns,
198 const char *prefix, const char *value);
199
208const char *xmlnode_get_attrib(const xmlnode *node, const char *attr);
209
219const char *xmlnode_get_attrib_with_namespace(const xmlnode *node, const char *attr, const char *xmlns);
220
227void xmlnode_remove_attrib(xmlnode *node, const char *attr);
228
236void xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns);
237
244void xmlnode_set_namespace(xmlnode *node, const char *xmlns);
245
253
260void xmlnode_set_prefix(xmlnode *node, const char *prefix);
261
268const char *xmlnode_get_prefix(const xmlnode *node);
269
280
290char *xmlnode_to_str(const xmlnode *node, int *len);
291
302char *xmlnode_to_formatted_str(const xmlnode *node, int *len);
303
315xmlnode *xmlnode_from_str(const char *str, gssize size);
316
325
332
349xmlnode *xmlnode_from_file(const char *dir, const char *filename,
350 const char *description, const char *process);
351
352#ifdef __cplusplus
353}
354#endif
355
356#endif /* _PURPLE_XMLNODE_H_ */
xmlnode * parent
The parent node or NULL.
Definition: xmlnode.h:56
xmlnode * child
The child node or NULL.
Definition: xmlnode.h:57
xmlnode * lastchild
The last child node or NULL.
Definition: xmlnode.h:58
xmlnode * next
The next node or NULL.
Definition: xmlnode.h:59
XMLNodeType type
The type of the node.
Definition: xmlnode.h:53
size_t data_sz
The size of the data.
Definition: xmlnode.h:55
char * xmlns
The namespace of the node.
Definition: xmlnode.h:52
char * name
The name of the node.
Definition: xmlnode.h:51
char * data
The data for the node.
Definition: xmlnode.h:54
GHashTable * namespace_map
The namespace map.
Definition: xmlnode.h:61
char * prefix
The namespace prefix if any.
Definition: xmlnode.h:60
const char * xmlnode_get_attrib(const xmlnode *node, const char *attr)
Gets an attribute from a node.
xmlnode * xmlnode_from_file(const char *dir, const char *filename, const char *description, const char *process)
Creates a node from a XML File.
xmlnode * xmlnode_get_child(const xmlnode *parent, const char *name)
Gets a child node named name.
char * xmlnode_get_data_unescaped(const xmlnode *node)
Gets unescaped data from a node.
const char * xmlnode_get_prefix(const xmlnode *node)
Returns the prefix of a node.
void xmlnode_insert_child(xmlnode *parent, xmlnode *child)
Inserts a node into a node as a child.
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 * xmlnode_get_parent(const xmlnode *child)
Gets the parent node.
void xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, const char *value)
Sets a namespaced attribute for a node.
void xmlnode_set_prefix(xmlnode *node, const char *prefix)
Sets the prefix of a node.
char * xmlnode_get_data(const xmlnode *node)
Gets (escaped) data from a node.
xmlnode * xmlnode_from_str(const char *str, gssize size)
Creates a node from a string of XML.
xmlnode * xmlnode_new(const char *name)
Creates a new xmlnode.
xmlnode * xmlnode_get_next_twin(xmlnode *node)
Gets the next node with the same name as node.
void xmlnode_insert_data(xmlnode *node, const char *data, gssize size)
Inserts data into a node.
xmlnode * xmlnode_new_child(xmlnode *parent, const char *name)
Creates a new xmlnode child.
void xmlnode_set_namespace(xmlnode *node, const char *xmlns)
Sets the namespace of a node.
_XMLNodeType
The valid types for an xmlnode.
Definition: xmlnode.h:39
@ XMLNODE_TYPE_ATTRIB
Has attributes.
Definition: xmlnode.h:41
@ XMLNODE_TYPE_DATA
Has data.
Definition: xmlnode.h:42
@ XMLNODE_TYPE_TAG
Just a tag.
Definition: xmlnode.h:40
void xmlnode_remove_attrib(xmlnode *node, const char *attr)
Removes an attribute from a node.
xmlnode * xmlnode_copy(const xmlnode *src)
Creates a new node from the source node.
void xmlnode_free(xmlnode *node)
Frees a node and all of its children.
char * xmlnode_to_formatted_str(const xmlnode *node, int *len)
Returns the node in a string of human readable xml.
void xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns)
Removes a namespaced attribute from a node.
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.
const char * xmlnode_get_namespace(xmlnode *node)
Returns the namespace of a node.
void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value)
Sets an attribute for a node.
xmlnode * xmlnode_get_child_with_namespace(const xmlnode *parent, const char *name, const char *xmlns)
Gets a child node named name in a namespace.
const char * xmlnode_get_attrib_with_namespace(const xmlnode *node, const char *attr, const char *xmlns)
Gets a namespaced attribute from a node.
char * xmlnode_to_str(const xmlnode *node, int *len)
Returns the node in a string of xml.
enum _XMLNodeType XMLNodeType
The valid types for an xmlnode.