/usr/share/doc/libxml2-devel/tutorial
NameSizeModeActions
images/-0755rm
apa.html21140644editdlrm
apb.html20260644editdlrm
apc.html30940644editdlrm
apd.html32320644editdlrm
ape.html30960644editdlrm
apf.html29490644editdlrm
apg.html30220644editdlrm
aph.html36000644editdlrm
api.html18990644editdlrm
ar01s02.html32980644editdlrm
ar01s03.html57180644editdlrm
ar01s04.html62230644editdlrm
ar01s05.html74220644editdlrm
ar01s06.html38490644editdlrm
ar01s07.html38660644editdlrm
ar01s08.html38940644editdlrm
ar01s09.html76030644editdlrm
includeaddattribute.c11360644editdlrm
includeaddkeyword.c13200644editdlrm
includeconvert.c18080644editdlrm
includegetattribute.c11710644editdlrm
includekeyword.c13510644editdlrm
includexpath.c14910644editdlrm
index.html59300644editdlrm
ix01.html25450644editdlrm
xmltutorial.pdf517090644editdlrm
Edit: /usr/share/doc/libxml2-devel/tutorial/includexpath.c (1491B)
#include xmlDocPtr getdoc (char *docname) { xmlDocPtr doc; doc = xmlParseFile(docname); if (doc == NULL ) { fprintf(stderr,"Document not parsed successfully. \n"); return NULL; } return doc; } xmlXPathObjectPtr getnodeset (xmlDocPtr doc, xmlChar *xpath){ xmlXPathContextPtr context; 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; } return result; } int main(int argc, char **argv) { char *docname; xmlDocPtr doc; xmlChar *xpath = (xmlChar*) "//keyword"; xmlNodeSetPtr nodeset; xmlXPathObjectPtr result; int i; xmlChar *keyword; if (argc <= 1) { printf("Usage: %s docname\n", argv[0]); return(0); } docname = argv[1]; doc = getdoc(docname); result = getnodeset (doc, xpath); if (result) { nodeset = result->nodesetval; for (i=0; i < nodeset->nodeNr; i++) { keyword = xmlNodeListGetString(doc, nodeset->nodeTab[i]->xmlChildrenNode, 1); printf("keyword: %s\n", keyword); xmlFree(keyword); } xmlXPathFreeObject (result); } xmlFreeDoc(doc); xmlCleanupParser(); return (1); } ]]>