| 403 | } |
| 404 | |
| 405 | static xmlNode *get_node_by_path(xmlNode *root, xml_element_t *path_el) |
| 406 | { |
| 407 | xmlNode *cur; |
| 408 | str n_name; |
| 409 | int i; |
| 410 | char *p; |
| 411 | |
| 412 | cur = root; |
| 413 | while (path_el) { |
| 414 | i = 0; |
| 415 | while (cur) { |
| 416 | n_name.s = (char *)cur->name; |
| 417 | n_name.len = strlen(n_name.s); |
| 418 | |
| 419 | /* skip an undefined namespace prefix that may appear |
| 420 | * in the element name */ |
| 421 | p = q_memchr(n_name.s, ':', n_name.len); |
| 422 | if (p) { |
| 423 | n_name.len = n_name.len - (p - n_name.s + 1); |
| 424 | n_name.s = p + 1; |
| 425 | } |
| 426 | |
| 427 | if (!str_strcmp(&path_el->tag, &n_name)) { |
| 428 | if (i == path_el->idx) |
| 429 | break; |
| 430 | else |
| 431 | i++; |
| 432 | } |
| 433 | |
| 434 | cur = xmlNextElementSibling(cur); |
| 435 | } |
| 436 | if (!cur) { |
| 437 | if (i != 0) { |
| 438 | LM_DBG("Invalid path for xml var - bad index [%d] for element: <%.*s>\n", |
| 439 | path_el->idx, path_el->tag.len, path_el->tag.s); |
| 440 | return NULL; |
| 441 | } else { |
| 442 | LM_DBG("Invalid path for xml var - no element named: <%.*s> \n", |
| 443 | path_el->tag.len, path_el->tag.s); |
| 444 | return NULL; |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | if (!path_el->next) |
| 449 | return cur; |
| 450 | else { |
| 451 | cur = cur->children; |
| 452 | path_el = path_el->next; |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | return NULL; |
| 457 | } |
| 458 | |
| 459 | |
| 460 | static int get_node_content(xmlNode *node, xmlBufferPtr xml_buf) |
no test coverage detected