|
Re: Parsing Using SAX: msg#00049text.xml.xerces-c.user
Ok, Im going to include my code for this problem. I get an error when the parse function is called: parser->parse(XMLfile)....Ive got no idea why Also this was formed from the SaxCount Code included with the Xerces distro. Currently I dont see it doing anything. I need to be able to change variable & containers in the DocumentHandler Class Cheers Alex bool prjLoad::loadXML_prj(char *prj_filename){ //Start XML Xerces Framework try { XMLPlatformUtils::Initialize(); } catch (const XMLException& toCatch) { char* message = XMLString::transcode(toCatch.getMessage()); cout << "Error during initialization! :\n" << message << "\n"; XMLString::release(&message); return false; } //Create New Parser (SAX) SAXParser* parser = new SAXParser(); //File Input Validation parser->setDoValidation(true); parser->setDoNamespaces(true); //Create our SAX handler object and install it on the parser (Doc & Error Handler) //Using Project as Handler parser->setDocumentHandler(prj); parser->setErrorHandler(prj); //Load File through Xerces XERCES_STD_QUALIFIER ifstream xmlFileHandle; xmlFileHandle.open(prj_filename); //Load Each Line From File To Array xmlFile bool flag = true; while (flag == true) { char token[1000]; //Set array to zeros memset(token,0,sizeof(token)); //Sequential Search if(!(xmlFileHandle.eof())){ xmlFileHandle.getline(token, sizeof(token)); //Check If Line Contains Anything if(!(token)) continue; else { //Load into New Derived Variable for overloading & Safety const char *XMLfile = token; //Debug cout << "Parsing: " << XMLfile << endl; //ERROR WIPE -> NEEDS IMPLIMENTING try { parser->parse(XMLfile); } catch(int debug /*Use Exception in class*/){ cout << "ERROR OCCURED" << endl; } } } //ELSE STATEMENT FOR EOF-> Set Flag to false therefore exiting while loop else flag = false; } return true; } appleGuy wrote: > > Its Ok, > > I needed to inheirt from the handlerbase class > > > Cheers > ALEX > > > > appleGuy wrote: >> >> Hi, >> >> Ive finally started to get going using Sax. Now im using the Samples to >> help coding my own project. >> >> Looking at Sax Count, they seem to have created their own handler class >> (saxcounthandler): >> >> SAXCountHandlers handler; >> parser->setDocumentHandler(&handler); >> parser->setErrorHandler(&handler); >> >> How can they do this as The type needed in setDocumentHandler needs to be >> type DocumentHandler. >> >> When I try to use my custom class as a handler, it gives an error...what >> is special about the SaxCountHandlers..? >> >> Ive used pointers,. they have dereferenced an object, surely im doing the >> same thing? >> >> Many Thanks >> Alex >> >> p.s: Also by DocumentHandler, what does this do exactly. Im thinking its >> the controller for the parsing. I.e you can use the parsed data to modify >> the handler and visa-versa >> >> >> >> >> > > -- View this message in context: http://www.nabble.com/Parsing-Using-SAX-tf2835675.html#a7918375 Sent from the Xerces - C - Users mailing list archive at Nabble.com. |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Parsing Using SAX: 00049, appleGuy |
|---|---|
| Next by Date: | Re: Parsing Using SAX: 00049, appleGuy |
| Previous by Thread: | Re: Parsing Using SAXi: 00049, appleGuy |
| Next by Thread: | Re: Parsing Using SAX: 00049, appleGuy |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |