summaryrefslogtreecommitdiff
path: root/doc/tutorial/includexpath.c
diff options
context:
space:
mode:
Diffstat (limited to 'doc/tutorial/includexpath.c')
-rw-r--r--doc/tutorial/includexpath.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/doc/tutorial/includexpath.c b/doc/tutorial/includexpath.c
index 7e8bc37..6b66e60 100644
--- a/doc/tutorial/includexpath.c
+++ b/doc/tutorial/includexpath.c
@@ -22,12 +22,21 @@ getnodeset (xmlDocPtr doc, xmlChar *xpath){
xmlXPathObjectPtr result;
context = xmlXPathNewContext(doc);
+ if (context == NULL) {
+ printf("Error in xmlXPathNewContext\n");
+ return NULL;
+ }
result = xmlXPathEvalExpression(xpath, context);
+ xmlXPathFreeContext(context);
+ if (result == NULL) {
+ printf("Error in xmlXPathEvalExpression\n");
+ return NULL;
+ }
if(xmlXPathNodeSetIsEmpty(result->nodesetval)){
+ xmlXPathFreeObject(result);
printf("No result\n");
return NULL;
}
- xmlXPathFreeContext(context);
return result;
}
int
@@ -62,4 +71,4 @@ main(int argc, char **argv) {
xmlCleanupParser();
return (1);
}
-]]>
+]]> \ No newline at end of file