xmlnode.h

Go to the documentation of this file.
00001 
00006 /* purple
00007  *
00008  * Purple is the legal property of its developers, whose names are too numerous
00009  * to list here.  Please refer to the COPYRIGHT file distributed with this
00010  * source distribution.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
00025  */
00026 #ifndef _PURPLE_XMLNODE_H_
00027 #define _PURPLE_XMLNODE_H_
00028 
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032 
00036 typedef enum _XMLNodeType
00037 {
00038     XMLNODE_TYPE_TAG,       
00039     XMLNODE_TYPE_ATTRIB,        
00040     XMLNODE_TYPE_DATA       
00041 } XMLNodeType;
00042 
00046 typedef struct _xmlnode xmlnode;
00047 struct _xmlnode
00048 {
00049     char *name;         
00050     char *xmlns;        
00051     XMLNodeType type;       
00052     char *data;         
00053     size_t data_sz;         
00054     struct _xmlnode *parent;    
00055     struct _xmlnode *child;     
00056     struct _xmlnode *lastchild; 
00057     struct _xmlnode *next;      
00058     char *prefix;               
00059     GHashTable *namespace_map;  
00060 };
00061 
00069 xmlnode *xmlnode_new(const char *name);
00070 
00079 xmlnode *xmlnode_new_child(xmlnode *parent, const char *name);
00080 
00087 void xmlnode_insert_child(xmlnode *parent, xmlnode *child);
00088 
00097 xmlnode *xmlnode_get_child(const xmlnode *parent, const char *name);
00098 
00108 xmlnode *xmlnode_get_child_with_namespace(const xmlnode *parent, const char *name, const char *xmlns);
00109 
00117 xmlnode *xmlnode_get_next_twin(xmlnode *node);
00118 
00127 void xmlnode_insert_data(xmlnode *node, const char *data, gssize size);
00128 
00137 char *xmlnode_get_data(xmlnode *node);
00138 
00147 char *xmlnode_get_data_unescaped(xmlnode *node);
00148 
00156 void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value);
00157 
00166 void xmlnode_set_attrib_with_prefix(xmlnode *node, const char *attr, const char *prefix, const char *value);
00167 
00176 void xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, const char *value);
00177 
00186 const char *xmlnode_get_attrib(xmlnode *node, const char *attr);
00187 
00197 const char *xmlnode_get_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns);
00198 
00205 void xmlnode_remove_attrib(xmlnode *node, const char *attr);
00206 
00214 void xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns);
00215 
00222 void xmlnode_set_namespace(xmlnode *node, const char *xmlns);
00223 
00230 const char *xmlnode_get_namespace(xmlnode *node);
00231 
00238 void xmlnode_set_prefix(xmlnode *node, const char *prefix);
00239 
00246 const char *xmlnode_get_prefix(const xmlnode *node);
00247 
00257 char *xmlnode_to_str(const xmlnode *node, int *len);
00258 
00269 char *xmlnode_to_formatted_str(const xmlnode *node, int *len);
00270 
00282 xmlnode *xmlnode_from_str(const char *str, gssize size);
00283 
00291 xmlnode *xmlnode_copy(const xmlnode *src);
00292 
00298 void xmlnode_free(xmlnode *node);
00299 
00300 #ifdef __cplusplus
00301 }
00302 #endif
00303 
00304 #endif /* _PURPLE_XMLNODE_H_ */