Ignore:
Timestamp:
Jun 1, 2009 9:28:28 AM (15 years ago)
Author:
bennylp
Message:

Ticket #868: Added functions to search XML child nodes recursively

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib-util/include/pjlib-util/xml.h

    r2394 r2727  
    150150 
    151151/** 
    152  * Find first node with the specified name. 
     152 * Find first direct child node with the specified name. 
    153153 * 
    154154 * @param parent    Parent node. 
     
    157157 * @return          XML node found or NULL. 
    158158 */ 
    159 PJ_DECL(pj_xml_node*) pj_xml_find_node(pj_xml_node *parent, const pj_str_t *name); 
    160  
    161 /** 
    162  * Find first node with the specified name. 
     159PJ_DECL(pj_xml_node*) pj_xml_find_node(const pj_xml_node *parent,  
     160                                       const pj_str_t *name); 
     161 
     162/** 
     163 * Find next direct child node with the specified name. 
    163164 * 
    164165 * @param parent    Parent node. 
     
    168169 * @return          XML node found or NULL. 
    169170 */ 
    170 PJ_DECL(pj_xml_node*) pj_xml_find_next_node(pj_xml_node *parent, pj_xml_node *node, 
     171PJ_DECL(pj_xml_node*) pj_xml_find_next_node(const pj_xml_node *parent,  
     172                                            const pj_xml_node *node, 
    171173                                            const pj_str_t *name); 
    172174 
    173175/** 
    174  * Find first attribute within a node with the specified name and optional value. 
     176 * Recursively find the first node with the specified name in the child nodes 
     177 * and their children. 
     178 * 
     179 * @param parent    Parent node. 
     180 * @param name      Node name to find. 
     181 * 
     182 * @return          XML node found or NULL. 
     183 */ 
     184PJ_DECL(pj_xml_node*) pj_xml_find_node_rec(const pj_xml_node *parent,  
     185                                           const pj_str_t *name); 
     186 
     187 
     188/** 
     189 * Find first attribute within a node with the specified name and optional  
     190 * value. 
    175191 * 
    176192 * @param node      XML Node. 
     
    180196 * @return          XML attribute found, or NULL. 
    181197 */ 
    182 PJ_DECL(pj_xml_attr*) pj_xml_find_attr(pj_xml_node *node, const pj_str_t *name, 
     198PJ_DECL(pj_xml_attr*) pj_xml_find_attr(const pj_xml_node *node,  
     199                                       const pj_str_t *name, 
    183200                                       const pj_str_t *value); 
    184201 
     
    188205 * 
    189206 * @param parent    Parent node. 
    190  * @param name      Optional name. 
     207 * @param name      Optional name. If this is NULL, the name will not be 
     208 *                  matched. 
    191209 * @param data      Data to be passed to matching function. 
    192210 * @param match     Optional matching function. 
     
    194212 * @return          The first matched node, or NULL. 
    195213 */ 
    196 PJ_DECL(pj_xml_node*) pj_xml_find( pj_xml_node *parent, const pj_str_t *name, 
     214PJ_DECL(pj_xml_node*) pj_xml_find( const pj_xml_node *parent,  
     215                                   const pj_str_t *name, 
    197216                                   const void *data,  
    198                                    pj_bool_t (*match)(pj_xml_node *, const void*)); 
     217                                   pj_bool_t (*match)(const pj_xml_node *,  
     218                                                      const void*)); 
     219 
     220 
     221/** 
     222 * Recursively find a child node with the specified name and match the  
     223 * function. 
     224 * 
     225 * @param parent    Parent node. 
     226 * @param name      Optional name. If this is NULL, the name will not be 
     227 *                  matched. 
     228 * @param data      Data to be passed to matching function. 
     229 * @param match     Optional matching function. 
     230 * 
     231 * @return          The first matched node, or NULL. 
     232 */ 
     233PJ_DECL(pj_xml_node*) pj_xml_find_rec(const pj_xml_node *parent,  
     234                                      const pj_str_t *name, 
     235                                      const void *data,  
     236                                      pj_bool_t (*match)(const pj_xml_node*,  
     237                                                         const void*)); 
    199238 
    200239 
Note: See TracChangeset for help on using the changeset viewer.