Overview
Features
Download
Documentation
Community
Add-Ons & Services

processingInstruction() in contentHandler never gets called?

A general discussion forum.

processingInstruction() in contentHandler never gets called?

Postby quirxi123 » 09 May 2008, 11:50

Hello,

have got a problem that I am not able to solve by myself, so I hoped that someone here in this forum can give me some advice...

The problem is following:

There is a class that is derived from XML ContentHandler and reacts to the various startElement/endElements events.
Since I need to know the encoding of the XML file that is beeing parsed I tried to override
processingInstruction() in order to get the encoding string:

Code: Select all

(void processingInstruction(const XMLString& target, const XMLString& dat))

But the problem is that this method never gets called ?!
Do I have forgotten/overseen something ?
Probably I have to set a flag or something else in order to make this work?

thanks and regards,
Arno
quirxi123
 
Posts: 6
Joined: 21 Apr 2008, 10:00

Re: processingInstruction() in contentHandler never gets called?

Postby guenter » 09 May 2008, 13:56

The XML declaration is not a Processing Instruction (despite the similarity in syntax), so the processingInstruction() member function from your content handler won't be called.

There is currently no way to find out the document's encoding by asking the XML parser. However, the underlying expat parser could provide this information (via the XML_XmlDeclHandler callback).

The way to implement this properly is to implement the SAX2 ext Locator2 interface, which has getXMLVersion() and getEncoding() methods. Doing that should not be too hard.

guenter
 
Posts: 1157
Joined: 11 Jul 2006, 16:27
Location: Austria


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests