xpath1.c revision 38ae7e4efe803ea78b6499cd05a394db32623e41
/**
* section: XPath
* synopsis: Evaluate XPath expression and prints result node set.
* purpose: Shows how to evaluate XPath expression and register
* known namespaces in XPath context.
* usage: xpath1 <xml-file> <xpath-expr> [<known-ns-list>]
* author: Aleksey Sanin
* copy: see Copyright for the status of this software.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <libxml/xpathInternals.h>
#if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_SAX1_ENABLED)
int execute_xpath_expression(const char* filename, const xmlChar* xpathExpr, const xmlChar* nsList);
int
/* Parse command line and process file */
return(-1);
}
/* Init libxml */
/* Do the main job */
return(-1);
}
/* Shutdown libxml */
/*
* this is to debug memory for regression tests
*/
return 0;
}
/**
* usage:
* @name: the program name.
*
* Prints usage information.
*/
static void
}
/**
* execute_xpath_expression:
* @filename: the input XML filename.
* @xpathExpr: the xpath expression for evaluation.
* @nsList: the optional list of known namespaces in
* "<prefix1>=<href1> <prefix2>=href2> ..." format.
*
* Parses input XML file, evaluates XPath expression and prints results.
*
* Returns 0 on success and a negative value otherwise.
*/
int
/* Load XML document */
return(-1);
}
/* Create xpath evaluation context */
return(-1);
}
/* Register namespaces from list (if any) */
return(-1);
}
/* Evaluate xpath expression */
return(-1);
}
/* Print results */
/* Cleanup */
return(0);
}
/**
* register_namespaces:
* @xpathCtx: the pointer to an XPath context.
* @nsList: the list of known namespaces in
* "<prefix1>=<href1> <prefix2>=href2> ..." format.
*
* Registers namespaces from @nsList in @xpathCtx.
*
* Returns 0 on success and a negative value otherwise.
*/
int
return(-1);
}
/* skip spaces */
if((*next) == '\0') break;
/* find prefix */
return(-1);
}
*(next++) = '\0';
/* find href */
*(next++) = '\0';
}
/* do register namespace */
return(-1);
}
}
return(0);
}
/**
* print_xpath_nodes:
* @nodes: the nodes set.
* @output: the output file handle.
*
* Prints the @nodes content to @output.
*/
void
int size;
int i;
for(i = 0; i < size; ++i) {
} else {
}
} else {
}
} else {
}
}
}
#else
int main(void) {
exit(1);
}
#endif