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 };
00059 
00067 xmlnode *xmlnode_new(const char *name);
00068 
00077 xmlnode *xmlnode_new_child(xmlnode *parent, const char *name);
00078 
00085 void xmlnode_insert_child(xmlnode *parent, xmlnode *child);
00086 
00095 xmlnode *xmlnode_get_child(const xmlnode *parent, const char *name);
00096 
00106 xmlnode *xmlnode_get_child_with_namespace(const xmlnode *parent, const char *name, const char *xmlns);
00107 
00115 xmlnode *xmlnode_get_next_twin(xmlnode *node);
00116 
00125 void xmlnode_insert_data(xmlnode *node, const char *data, gssize size);
00126 
00135 char *xmlnode_get_data(xmlnode *node);
00136 
00145 char *xmlnode_get_data_unescaped(xmlnode *node);
00146 
00154 void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value);
00155 
00164 void xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, const char *value);
00165 
00174 const char *xmlnode_get_attrib(xmlnode *node, const char *attr);
00175 
00185 const char *xmlnode_get_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns);
00186 
00193 void xmlnode_remove_attrib(xmlnode *node, const char *attr);
00194 
00202 void xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns);
00203 
00210 void xmlnode_set_namespace(xmlnode *node, const char *xmlns);
00211 
00218 const char *xmlnode_get_namespace(xmlnode *node);
00219 
00229 char *xmlnode_to_str(xmlnode *node, int *len);
00230 
00241 char *xmlnode_to_formatted_str(xmlnode *node, int *len);
00242 
00254 xmlnode *xmlnode_from_str(const char *str, gssize size);
00255 
00263 xmlnode *xmlnode_copy(const xmlnode *src);
00264 
00270 void xmlnode_free(xmlnode *node);
00271 
00272 #ifdef __cplusplus
00273 }
00274 #endif
00275 
00276 #endif /* _PURPLE_XMLNODE_H_ */