Bassem Srouji wrote:
Hi,
I am using xerces 2.8.0
I create my parser like that:
SAX2XMLReader* pParser = XMLReaderFactory::createXMLReader();
pParser->setContentHandler(MyOwnHandler);
pParser->setErrorHandler(MyOwnHandler);
pParser->setLexicalHandler(MyOwnHandler);
pParser->setEntityResolver(MyOwnHandler);
and then I call the pParser->parse(MyFile.xml);
Now, I want to get the line number of the element that is being parsed from the
MyOwnHandler::startElement function
I am not able to figure out how to get to the getLineNumber function of parser
from my SAX2XMLReader object
Well, you could pass a pointer to the parser to your handler, but
SAX2XMLReader does not have a getLineNumber() member function.
The standard way to do this is to override setDocumentLocator() function
in your ContentHandler, then save the Locator pointer. At any point
during a parse, you can call member functions of the Locator instance to
get line number information.
Dave