~ubuntu-branches/ubuntu/maverick/newsbeuter/maverick

« back to all changes in this revision

Viewing changes to testpp.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Nico Golde
  • Date: 2007-04-21 19:44:35 UTC
  • Revision ID: james.westby@ubuntu.com-20070421194435-21g6134ws2yvarlt
Tags: upstream-0.3
ImportĀ upstreamĀ versionĀ 0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <xmlpullparser.h>
 
2
#include <fstream>
 
3
#include <iostream>
 
4
 
 
5
using namespace std;
 
6
using namespace newsbeuter;
 
7
 
 
8
#ifdef _TESTPP
 
9
int main(int argc, char * argv[]) {
 
10
        if (argc < 2)
 
11
                return 1;
 
12
        xmlpullparser xpp;
 
13
        fstream f(argv[1]);
 
14
        xpp.setInput(f);
 
15
 
 
16
        for (xmlpullparser::event e = xpp.next(); e != xmlpullparser::END_DOCUMENT; e = xpp.next()) {
 
17
                switch (e) {
 
18
                        case xmlpullparser::START_TAG:
 
19
                                cout << "start tag: " << xpp.getText() << endl;
 
20
                                for (unsigned int i=0;i<xpp.getAttributeCount();++i) {
 
21
                                        cout << "  attribute: " << xpp.getAttributeName(i) << " = " << xpp.getAttributeValue(i) << endl;
 
22
                                }
 
23
                                break;
 
24
                        case xmlpullparser::TEXT:
 
25
                                cout << "text: " << xpp.getText() << endl;
 
26
                                break;
 
27
                        case xmlpullparser::END_TAG:
 
28
                                cout << "end tag: " << xpp.getText() << endl;
 
29
                                break;
 
30
                }
 
31
        }
 
32
 
 
33
        return 0;
 
34
}
 
35
#endif