summaryrefslogtreecommitdiffstats
path: root/testpp.cpp
blob: 5c4d5ec6f66e8de9f59017e0d2672790d9c2cd9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <xmlpullparser.h>
#include <fstream>
#include <iostream>

using namespace std;
using namespace newsbeuter;

#ifdef _TESTPP
int main(int argc, char * argv[]) {
	if (argc < 2)
		return 1;
	xmlpullparser xpp;
	fstream f(argv[1]);
	xpp.setInput(f);

	for (xmlpullparser::event e = xpp.next(); e != xmlpullparser::END_DOCUMENT; e = xpp.next()) {
		switch (e) {
			case xmlpullparser::START_TAG:
				cout << "start tag: " << xpp.getText() << endl;
				for (unsigned int i=0;i<xpp.getAttributeCount();++i) {
					cout << "  attribute: " << xpp.getAttributeName(i) << " = " << xpp.getAttributeValue(i) << endl;
				}
				break;
			case xmlpullparser::TEXT:
				cout << "text: " << xpp.getText() << endl;
				break;
			case xmlpullparser::END_TAG:
				cout << "end tag: " << xpp.getText() << endl;
				break;
		}
	}

	return 0;
}
#endif