Hello xerces-c-dev ! I aim to produce a simple sample looking like (this is no code... just idea )
somewhere in a code : for(i=0; i<Imax; i++) { computesomething(i); writeintoXMLfile(data[i]); } with data[i] containing anything we want... This writeintoWMLfile could handle the data and finally output it into the XML file. I'm not very comfortable with DOM and SAX but as far as i've understood, SAX is event oriented. That's exaclty what i need. I have several events or data to put at some particular time into files. Reagading how long the programm is working i could produce data to put into file. That's an other reason to choose SAX and not DOM. (if i'm not right just tell me!!!) In order to do this I'm currently using a slightly modified SAX2PrintHandlers version : (here it is) : SAX2PrintHandlers::SAX2PrintHandlers( const char* const encodingName, const XMLFormatter::UnRepFlags unRepFlags, const bool expandNamespaces) : fTarget(new LocalFileFormatTarget(goutputfile)) , fFormatter(encodingName, fTarget, XMLFormatter::NoEscapes, unRepFlags ), fExpandNS ( expandNamespaces ) { fFormatter << gXMLDecl1 << fFormatter.getEncodingName() << gXMLDecl2; } SAX2PrintHandlers::~SAX2PrintHandlers() { delete fTarget; } And i thought to use the writeChars method to realize what i wrote about. Is there any way to do it ? Here is what i tried (i'm no programmer so please be tolerant :) ): in the SAX2Print sample : try { SAX2PrintHandlers handler(encodingName, unRepFlags, expandNamespaces); parser->setContentHandler(&handler); parser->setErrorHandler(&handler); parser->parse(xmlFile); handler.writeChars((XMLByte*)"test"); errorCount = parser->getErrorCount(); } void SAX2PrintHandlers::writeChars(const XMLByte* const toWrite) { writeChars(toWrite, 1, &fFormatter); } void SAX2PrintHandlers::writeChars(const XMLByte* const toWrite, const unsigned int count, XMLFormatter* const formatter) { XERCES_STD_QUALIFIER cout.write((char *) toWrite, (int) count); XERCES_STD_QUALIFIER cout.flush(); // this do nothing FILE* sortie; //sortie = fopen("/home/[..]/XML/src/xerces-c-src_2_5_0/work/fichier_sortie.xml","a"); sortie = fopen(goutputfile,"a"); // For this one, just dump them to the standard output // Surprisingly, Solaris was the only platform on which // required the char* cast to print out the string correctly. // Without the cast, it was printing the pointer value in hex. // Quite annoying, considering every other platform printed // the string with the explicit cast to char* below. fwrite((char*)toWrite, 1, count, sortie); fclose(sortie); } Hope i'll hear good news soon ! Olivier --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]