From 783fa8dd7d7de47dee073ab73e6213a2d85f3f6e Mon Sep 17 00:00:00 2001 From: ehofman Date: Tue, 16 Jun 2009 12:30:39 +0000 Subject: [PATCH] a utility to print an xml file as a property tree --- utils/xmlgrep/Makefile.am | 3 ++ utils/xmlgrep/printtree.c | 82 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 utils/xmlgrep/printtree.c diff --git a/utils/xmlgrep/Makefile.am b/utils/xmlgrep/Makefile.am index 167f15a9d..084efb4ee 100644 --- a/utils/xmlgrep/Makefile.am +++ b/utils/xmlgrep/Makefile.am @@ -12,6 +12,9 @@ testxml_LDADD = libxmlconf.a printxml_SOURCES = $(xml_SOURCE) printxml.c printxml_LDADD = libxmlconf.a +printtree_SOURCES = $(xml_SOURCE) printtree.c +printtree_LDADD = libxmlconf.a + xmlgrep_SOURCES = $(xml_SOURCE) xmlgrep.c xml.c xml.h xmlgrep_LDADD = libxmlconf.a diff --git a/utils/xmlgrep/printtree.c b/utils/xmlgrep/printtree.c new file mode 100644 index 000000000..674a7d14a --- /dev/null +++ b/utils/xmlgrep/printtree.c @@ -0,0 +1,82 @@ + +#include +#include + +#include "xml.h" + +void print_xml(void *, char *, int); + +int main(int argc, char **argv) +{ + if (argc < 1) + { + printf("usage: printtree \n\n"); + } + else + { + void *rid; + + rid = xmlOpen(argv[1]); + if (xmlErrorGetNo(rid, 0) != XML_NO_ERROR) + { + printf("%s\n", xmlErrorGetString(rid, 1)); + } + else if (rid) + { + unsigned int i, num; + void *xid; + + xid = xmlMarkId(rid); + num = xmlNodeGetNum(xid, "*"); + for (i=0; i