Hi Alberto, Thanks for the quick reply.
So to write out to memory I used XMLFormatTarget *myFormTarget; myFormTarget = new MemBufFormatTarget(); theSerializer->writeNode(myFormTarget, *doc); This seems to have worked, problem is now reading back in. You say to read in I use MemBufInputSource object, but I am confused as to how I get the MemBufInputSource to point to the MemBufFormatTarget (myFormTarget) which contains the data I wrote earlier. Are they interchangable? To clarify, I have written the data to myFormTarget, of type MemBufFormatTarget. now I want to read it back in using myinput of type MemBufInputSource but how can I get myinput to source the input from myFormTarget? On Mon, Jul 21, 2008 at 9:20 AM, Alberto Massari <[EMAIL PROTECTED]> wrote: > Daniel Burrell wrote: > >> So I understand it is possible to parse an xml file from a location on >> disk >> using: >> parser->parse(gXmlFile); >> where gXmlFile is the file location. >> >> I would like to serialise the contents of dom to 'memory' rather than >> disk, >> then parse it back in from memory >> >> Is this possible? >> > > In order to save to memory, you can use DOMWriter::writeToString (that > always saves using UTF-16) or DOMWriter::writeNode using as XMLFormatTarget > an instance of MemBufFormatTarget (in this case, the encoding can be > specified using DOMWriter::setEncoding). As for loading back from the memory > buffer, you can use the parse(InputSource&) overload, using a > MemBufInputSource object wrapping your data. > > Alberto > >
