Changeset d912fe4
- Timestamp:
- 2010-08-14T23:00:53Z (14 years ago)
- Branches:
- master
- Children:
- d97f51b
- Parents:
- 4fc95c5
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/xmltree.c
r4fc95c5 rd912fe4 479 479 } 480 480 481 /* More advanced than the one above, understands something like 482 ../foo/bar to find a subnode bar of a node foo which is a child 483 of node's parent. Pass the node directly, not its list of children. */ 484 struct xt_node *xt_find_path( struct xt_node *node, const char *name ) 485 { 486 while( name && *name && node ) 487 { 488 char *colon, *slash; 489 int n; 490 491 if( ( slash = strchr( name, '/' ) ) ) 492 n = slash - name; 493 else 494 n = strlen( name ); 495 496 if( strncmp( name, "..", n ) == 0 ) 497 { 498 node = node->parent; 499 } 500 else 501 { 502 node = node->children; 503 504 while( node ) 505 { 506 if( g_strncasecmp( node->name, name, n ) == 0 || 507 ( ( colon = strchr( node->name, ':' ) ) && 508 g_strncasecmp( colon + 1, name, n ) == 0 ) ) 509 break; 510 511 node = node->next; 512 } 513 } 514 515 name = slash ? slash + 1 : NULL; 516 } 517 518 return node; 519 } 520 481 521 char *xt_find_attr( struct xt_node *node, const char *key ) 482 522 { -
lib/xmltree.h
r4fc95c5 rd912fe4 89 89 void xt_free( struct xt_parser *xt ); 90 90 struct xt_node *xt_find_node( struct xt_node *node, const char *name ); 91 struct xt_node *xt_find_path( struct xt_node *node, const char *name ); 91 92 char *xt_find_attr( struct xt_node *node, const char *key ); 92 93
Note: See TracChangeset
for help on using the changeset viewer.