/xmlbench/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/xmlbench/trunk

« back to all changes in this revision

Viewing changes to parse/libxml-pull.c

  • Committer: Suren A. Chilingaryan
  • Date: 2009-10-08 03:17:59 UTC
  • Revision ID: csa@dside.dyndns.org-20091008031759-u5ys779huye7feni
LibXML Pull Parser, FAXPP Parser, Mono security benchmark, multiple fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <sys/time.h>
 
3
#include <libxml/xmlreader.h>
 
4
 
 
5
#include "tools.h"
 
6
 
 
7
//xmlSAXHandler handler;
 
8
 
 
9
void initXML(struct TestData *td) {
 
10
    xmlInitParser();
 
11
//    initxmlDefaultSAXHandler(&handler,0);
 
12
}
 
13
 
 
14
void releaseXML(struct TestData *td) {
 
15
    xmlCleanupParser();
 
16
}
 
17
 
 
18
void parseXML(struct TestData *td, unsigned long iter) {
 
19
    int res;
 
20
    xmlTextReaderPtr ctx;
 
21
 
 
22
#ifdef DTD_VALIDATION
 
23
    ctx = xmlReaderForMemory(td->xml, td->xmllen, "xml", NULL, XML_PARSE_DTDVALID);
 
24
#else
 
25
    ctx = xmlReaderForMemory(td->xml, td->xmllen, "xml", NULL, 0);
 
26
#endif
 
27
 
 
28
    if (!ctx) {
 
29
        printf("Parsing is failed\n");
 
30
        exit(1);
 
31
    }
 
32
    res = xmlTextReaderRead(ctx);
 
33
    while (res == 1) {
 
34
        //printf("%u\n", xmlTextReaderNodeType(ctx));
 
35
        if (xmlTextReaderNodeType(ctx) == XML_READER_TYPE_ELEMENT) {
 
36
            //xmlTextReaderMoveToFirstAttribute(ctx);
 
37
            while (xmlTextReaderMoveToNextAttribute(ctx));
 
38
            xmlTextReaderMoveToElement(ctx);
 
39
        }
 
40
        res = xmlTextReaderRead(ctx);
 
41
    }
 
42
    xmlFreeTextReader(ctx);
 
43
 
 
44
    if (res) {
 
45
        printf("Parsing is failed with code: %i\n", res);
 
46
        exit(1);
 
47
    }
 
48
}
 
49
 
 
50
int main(int argc, char *argv[]) {
 
51
    return Test(argc,argv);
 
52
}