I work on a large project using ROOT and I am optimizing the code a little.
I need to parse an XML file but not the whole file, just the “first part”. The second part which could be long is just data that I don’t need.
I use a SaxParser because my xml file could be heavy. I am looking for interrupting it after the first part but I don’t find how to do it.
There is a link between the TSAXParser and my user-defined handler but i didn’t manage to link the “StopParser()” method inherited from TXMLParser. I also failed raising an exception and catching because it seems to be first caught by the TSAXParser.
Have I forgotten something simple? May somebody help?
I just tried this. I pass the saxParser object to my saxHandler constructor and store it as a field.
The Problem is that I cannot call stopParser() which is a protected method. I could delcare my class saxHandler as a children of TSAXParser to have access to this method but it’s quite ugly and it’s not conceptually correct.
The compilation was OK but when I run my program I have a segfault. Here is gdb output :
Apparently everything is ok until I launch the parsing itself. Afterwards a buffer seemed to be created and memory is moved/allocated which seems to disturb the pointer to the saxParser I have in my SaxHandler class.
I commented the StopParser line, the problem was still there.
I tried to pass a reference to the saxParser pointer, same problem.