3 #include <libxml/xmlreader.h>
6 (void * ctx, const xmlChar * ch, int len) { return; }
9 (void *ctx, const xmlChar *ch, int len) { return; }
12 (void *ctx, const xmlChar *value, int len) { return; }
15 (void *ctx, const xmlChar *name, const xmlChar **atts) { return; }
17 void start_element_ns_cb
18 (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI,
19 int nb_namespaces, const xmlChar **namespaces, int nb_attributes,
20 int nb_defaulted, const xmlChar **attributes)
23 void end_element_ns_cb
24 (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI)
28 (void *ctx, const char *msg, ...) {
29 fprintf(stderr, "Error: %s\n", msg);
34 main(int argc, char *argv[])
39 FILE *xmlfile = stdin;
40 struct timeval timing1, timing2;
41 xmlParserCtxtPtr ctxt;
43 NULL, /* internalSubsetSAXFunc */
44 NULL, /* isStandaloneSAXFunc */
45 NULL, /* hasInternalSubsetSAXFunc */
46 NULL, /* hasExternalSubsetSAXFunc */
47 NULL, /* resolveEntitySAXFunc */
48 NULL, /* getEntitySAXFunc */
49 NULL, /* entityDeclSAXFunc */
50 NULL, /* notationDeclSAXFunc */
51 NULL, /* attributeDeclSAXFunc */
52 NULL, /* elementDeclSAXFunc */
53 NULL, /* unparsedEntityDeclSAXFunc */
54 NULL, /* setDocumentLocatorSAXFunc */
55 NULL, /* startDocumentSAXFunc */
56 NULL, /* endDocumentSAXFunc */
57 start_element_cb, /* startElementSAXFunc */
58 NULL, /* endElementSAXFunc */
59 NULL, /* referenceSAXFunc */
60 characters_cb, /* charactersSAXFunc */
61 whitespace_cb, /* ignorableWhitespaceSAXFunc */
62 NULL, /* processingInstructionSAXFunc */
63 NULL, /* commentSAXFunc */
64 NULL, /* warningSAXFunc */
65 error_cb, /* errorSAXFunc */
66 NULL, /* fatalErrorSAXFunc */
67 NULL, /* getParameterEntitySAXFunc */
68 cdata_cb, /* cdataBlockSAXFunc */
69 NULL, /* externalSubsetSAXFunc */
70 XML_SAX2_MAGIC, /* initialized */
72 start_element_ns_cb, /* startElementNsSAX2Func */
73 end_element_ns_cb, /* startElementNsSAX2Func */
74 NULL /* xmlStructuredErrorFunc */
76 ctxt = xmlCreatePushParserCtxt(&sax, NULL, NULL, 0, NULL);
78 fprintf(stderr, "Can't instantiate parser\n");
81 gettimeofday(&timing1, NULL);
83 size_t len = fread(buf, 1, sizeof(buf), xmlfile);
84 done = len < sizeof(buf);
85 res = xmlParseChunk(ctxt, buf, len, 0);
87 fprintf(stderr, "Parse error\n");
91 gettimeofday(&timing2, NULL);
92 xmlFreeParserCtxt(ctxt);
93 fprintf(stdout, "%d\n",
94 ((timing2.tv_sec * 1000000 + timing2.tv_usec) -
95 (timing1.tv_sec * 1000000 + timing1.tv_usec)) / 1000);