I do not use RapidXML, but maybe my approach may solve your problem.
I started using Xerces, but I found it difficult, in addition to other minor annoyances, so I switched to CPPDOM. When I made the transition, I decided to create a set of wrapper classes so that my code does not depend on a specific XML engine, and I could transfer it to another if necessary.
I created my own classes to represent the main DOM objects (node, document, etc.). These classes use the internal pimpl idiom to use CPPDOM objects. Since my node object contains the “real” node object (from CPPDOM), I can control anything so that properly distributing and freeing the lines will not be a problem there.
Since my code is for CPPDOM, I don’t think it would be very useful for you, but I can publish it if you want.
By the way, if you already have too much code that already uses RapidXML, you can reproduce its interfaces in your wrapper classes. I did not do this because the code that Xerces used was not so long and I would still have to rewrite it.
Fabio ceconello
source share