21 fprintf(stderr,
"LGPL command line XML parser\n<tristan.lelong@libroxml.net>\n");
24void print_usage(
const char *progname)
26 fprintf(stderr,
"\nusage: %s [-q|-h] <filename> [/]<node1>/<node2>/<node3>/.../<nodeN>\n", progname);
27 fprintf(stderr,
"-q|--quiet: activate quiet mode\n");
28 fprintf(stderr,
"-c|--content: show content of node instead of name\n");
29 fprintf(stderr,
"-h|--help: display this message\n");
32int main(
int argc,
char **argv)
41 for (optind = 1; optind < argc; optind++) {
43 if (argv[optind][0] ==
'-') {
44 if (strcmp(argv[optind],
"--help") == 0) {
46 }
else if (strcmp(argv[optind],
"--content") == 0) {
48 }
else if (strcmp(argv[optind],
"--quiet") == 0) {
50 }
else if (strcmp(argv[optind],
"-h") == 0) {
52 }
else if (strcmp(argv[optind],
"-c") == 0) {
54 }
else if (strcmp(argv[optind],
"-q") == 0) {
82 perror(
"error parsing xml file");
86 if (argc < optind + 2)
91 for (j = 0; j < max; j++) {
97 fprintf(stdout,
"\n");
108 fprintf(stdout,
"ans[%d]: ", j);
109 fprintf(stdout,
"%s\n", c);
115 for (i = 0; i < nb_chld; i++) {
120 fprintf(stdout,
"ans[%d]: ", j);
124 fprintf(stdout,
"%s:", s);
126 fprintf(stdout,
"%s\n", c);
ROXML_API node_t ** roxml_xpath(node_t *n, char *path, int *nb_ans)
exec path function
ROXML_API void roxml_release(void *data)
memory cleanning function
ROXML_API int roxml_commit_fd(node_t *n, int fd, int human)
sync to file descriptor function
ROXML_API int roxml_get_chld_nb(node_t *n)
chlds number getter function
ROXML_API node_t * roxml_get_chld(node_t *n, char *name, int nth)
chld getter function
ROXML_API char * roxml_get_content(node_t *n, char *buffer, int bufsize, int *size)
content getter function
ROXML_API node_t * roxml_get_ns(node_t *n)
namespace getter function
ROXML_API char * roxml_get_name(node_t *n, char *buffer, int size)
name getter function
ROXML_API void roxml_close(node_t *n)
unload function
ROXML_API node_t * roxml_load_doc(char *filename)
load function for files