| 255 | } |
| 256 | |
| 257 | static xmlChar * |
| 258 | getString(xmlNodePtr cur, const char *xpath) { |
| 259 | xmlChar *ret = NULL; |
| 260 | xmlXPathObjectPtr res; |
| 261 | xmlXPathCompExprPtr comp; |
| 262 | |
| 263 | if ((cur == NULL) || (cur->doc == NULL) || (xpath == NULL)) |
| 264 | return(NULL); |
| 265 | ctxtXPath->doc = cur->doc; |
| 266 | ctxtXPath->node = cur; |
| 267 | comp = xmlXPathCompile(BAD_CAST xpath); |
| 268 | if (comp == NULL) { |
| 269 | fprintf(stderr, "Failed to compile %s\n", xpath); |
| 270 | return(NULL); |
| 271 | } |
| 272 | res = xmlXPathCompiledEval(comp, ctxtXPath); |
| 273 | xmlXPathFreeCompExpr(comp); |
| 274 | if (res == NULL) |
| 275 | return(NULL); |
| 276 | if (res->type == XPATH_STRING) { |
| 277 | ret = res->stringval; |
| 278 | res->stringval = NULL; |
| 279 | } |
| 280 | xmlXPathFreeObject(res); |
| 281 | return(ret); |
| 282 | } |
| 283 | |
| 284 | /************************************************************************ |
| 285 | * * |
no test coverage detected