#include "textwolf.hpp" #include "textwolf/istreamiterator.hpp" #include #include using namespace std; using namespace textwolf; int main( int argc, char *argv[] ) { if( argc != 2 ) { cerr << "Usage: test2 \n" << endl; return 1; } char *xmlFileName = argv[1]; ifstream xmlFile( xmlFileName ); if( !xmlFile.good( ) ) { cerr << "ERROR: Can't open file '" << xmlFileName << "'" << endl; return 1; } IStreamIterator isitr( xmlFile ); typedef enum { SITEMAP_LOC = 1 } XmlNodes; typedef XMLPathSelectAutomaton Automaton; Automaton atm; // //sitemap/loc content (*atm)--["sitemap"]["loc"]( ) = SITEMAP_LOC; typedef XMLPathSelect PathSelect; typedef XMLScanner Scanner; Scanner xsc( isitr ); PathSelect xsel( &atm ); Scanner::iterator ci, ce; for( ci = xsc.begin( ), ce = xsc.end( ); ci != ce; ci++ ) { if( ci->type( ) == Scanner::ErrorOccurred ) { throw std::runtime_error( ci->content( ) ); } PathSelect::iterator itr = xsel.push( ci->type( ), ci->content( ), ci->size( ) ); PathSelect::iterator end = xsel.end( ); for( ; itr != end; itr++ ) { if( *itr == SITEMAP_LOC ) { cout << ci->content( ) << endl; } } } }