123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #include <stdio.h>
- #include <libxml/parser.h>
- #include <libxml/tree.h>
- static void
- exampleFunc(const char *filename) {
- xmlParserCtxtPtr ctxt;
- xmlDocPtr doc;
-
- ctxt = xmlNewParserCtxt();
- if (ctxt == NULL) {
- fprintf(stderr, "Failed to allocate parser context\n");
- return;
- }
-
- doc = xmlCtxtReadFile(ctxt, filename, NULL, XML_PARSE_DTDVALID);
-
- if (doc == NULL) {
- fprintf(stderr, "Failed to parse %s\n", filename);
- } else {
-
- if (ctxt->valid == 0)
- fprintf(stderr, "Failed to validate %s\n", filename);
-
- xmlFreeDoc(doc);
- }
-
- xmlFreeParserCtxt(ctxt);
- }
- int main(int argc, char **argv) {
- if (argc != 2)
- return(1);
-
- LIBXML_TEST_VERSION
- exampleFunc(argv[1]);
-
- xmlCleanupParser();
-
- xmlMemoryDump();
- return(0);
- }
|