/* * tester.c : a small tester program for XML input. * * See Copyright for the status of this software. * * $Id$ */ #ifdef WIN32 #define HAVE_FCNTL_H #include #else #include #endif #include #ifdef HAVE_SYS_STAT_H #include #endif #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #include #include #include #include "parser.h" #include "tree.h" /* * Note: there is a couple of errors introduced on purpose. */ static CHAR buffer[] = "\n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ Jim Whitehead\n\ Roy Fielding\n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ "; void parseAndPrintFile(char *filename) { xmlDocPtr doc; /* * build an XML tree from a string; */ doc = xmlParseFile(filename); /* * print it. */ xmlDocDump(stdout, doc); /* * free it. */ xmlFreeDoc(doc); } void parseAndPrintBuffer(CHAR *buf) { xmlDocPtr doc; /* * build an XML tree from a string; */ doc = xmlParseDoc(buf); /* * print it. */ xmlDocDump(stdout, doc); /* * free it. */ xmlFreeDoc(doc); } int main(int argc, char **argv) { int i; if (argc > 1) { for (i = 1; i < argc ; i++) { parseAndPrintFile(argv[i]); } } else parseAndPrintBuffer(buffer); return(0); }