Hi,
I just took the startElement method from SAX2Count and copied it to my .hpp
(the definition) and my .cpp file (declaration). I did the same for the
characters method from SAX2Count. When i compile my project, the compiler
says that there is a ',' missing before '&'(in my .hpp and my .cpp file!).
How can that be? I copied both methods and chracters() is working fine,
while startElement(...) isn`t working!
void CHandler::startElement(const XMLCh* const uri
, const XMLCh* const localname
, const XMLCh* const qname
, const Attributes& attrs)
{
std:cout << "Found element...";
}
Has anyone a sample code fragment for startElement?
Thanks
Andre
> Hi Andre,
> you are missing a
>
> #include <xercesc/sax2/Attributes.hpp>
>
> in the CHandler.hpp file.
>
> Alberto
>
> At 13.43 15/06/2004 +0200, Andre Stock wrote:
> >Ok, you`re right i`m new to c++. But anyway i want to try to write it on
> my
> >own (or better with your help! ;-))
> >
> >That`s the CXercesTest.cpp file:
> >
> >#include "stdafx.h"
> >#include "CXercesTest.h"
> >#include "CHandler.hpp"
> >#include <xercesc/util/PlatformUtils.hpp>
> >#include <xercesc/sax2/SAX2XMLReader.hpp>
> >#include <xercesc/sax2/XMLReaderFactory.hpp>
> >#include <xercesc/sax2/DefaultHandler.hpp>
> >
> >
> >using namespace XERCES_CPP_NAMESPACE;
> >//using namespace std;
> >
> >//##ModelId=40C56B8B02DE
> >void CXercesTest::createXMLStream()
> >{
> >
> >}
> >
> >//##ModelId=40C56BC8003E
> >int CXercesTest::parseDocument()
> >{
> > try {
> > XMLPlatformUtils::Initialize();
> > }
> > catch (const XMLException& toCatch) {
> > char* message = XMLString::transcode(toCatch.getMessage());
> > std::cout << "Error during initialization! :\n";
> > std::cout << "Exception message is: \n"
> > << message << "\n";
> > XMLString::release(&message);
> > return 1;
> > }
> >
> > SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
> >
> >
> > CHandler* defaultHandler = new CHandler();
> > //DefaultHandler* defaultHandler = new DefaultHandler();
> > parser->setContentHandler(defaultHandler);
> > parser->setErrorHandler(defaultHandler);
> > try {
> > parser->parse("c:\\xmlFile.xml");
> > }
> > catch (const XMLException& toCatch) {
> > char* message = XMLString::transcode(toCatch.getMessage());
> > std::cout << "Exception message is: \n"
> > << message << "\n";
> > XMLString::release(&message);
> > return -1;
> > }
> > catch (const SAXParseException& toCatch) {
> > char* message = XMLString::transcode(toCatch.getMessage());
> > std::cout << "Exception message is: \n"
> > << message << "\n";
> > XMLString::release(&message);
> > return -1;
> > }
> > catch (...) {
> > std::cout << "Unexpected Exception \n" ;
> > return -1;
> > }
> >
> >}
> >
> >//##ModelId=40C56F5C0196
> >CXercesTest::CXercesTest()
> >{
> > this->createXMLStream();
> > this->parseDocument();
> >}
> >
> >I also created a file which inherits from DefaultHandler.hpp which is
> called
> >CHandler.hpp:
> >
> >#include <xercesc/sax/SAXParseException.hpp>
> >#include <xercesc/sax2/DefaultHandler.hpp>
> >#include <iostream>
> >
> >
> >class CHandler : public XERCES_CPP_NAMESPACE::DefaultHandler
> >{
> >public:
> > CHandler();
> > ~CHandler();
> > void startDocument();
> > void startElement (
> > const XMLCh* const uri,
> > const XMLCh* const localname,
> > const XMLCh* const qname,
> > const Attributes& attrs
> > );
> >
> >
> >};
> >
> >and CHandler.cpp:
> >#include <xercesc/util/XercesDefs.hpp>
> >#include <xercesc/util/XMLString.hpp>
> >#include "CHandler.hpp"
> >
> >//using namespace XERCES_CPP_NAMESPACE;
> >
> >
> >void CHandler::startDocument()
> >{
> > std::cout<< "Parsing in progress...!";
> >}
> >
> >void CHandler::startElement(
> > const XMLCh* const uri,
> > const XMLCh* const localname,
> > const XMLCh* const qname,
> > const Attributes& attrs
> > )
> >{
> > std::cout << "Found element...";
> >}
> >
> >CHandler::CHandler()
> >{
> >}
> >CHandler::~CHandler()
> >{
> >}
> >
> >and there is the problem, the compiler says "missing ',' before '&' in
> the
> >CHandler.hpp and CHandler.cpp file.
> >Just for the sake of completeness there is another class calling the
> >CXercesTest constructor.
> >I`m sorry bothering you, but i have to get it working as fast as
> possible...
> >when it`s to hard for me i`ll try the version with taking SAXPrint and
> >modify it!
> >Thanks in advance!
> >Andre
> >
> >--
> >"Sie haben neue Mails!" - Die GMX Toolbar informiert Sie beim Surfen!
> >Jetzt aktivieren unter http://www.gmx.net/info
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
+++ Jetzt WLAN-Router f�r alle DSL-Einsteiger und Wechsler +++
GMX DSL-Powertarife zudem 3 Monate gratis* http://www.gmx.net/dsl
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]