xerces-c-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alberto Massari <amass...@datadirect.com>
Subject Re: serialise to memory, parse back in from memory
Date Mon, 21 Jul 2008 08:20:39 GMT
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


Mime
View raw message