Hi,
use the writeToString method and then transcode to whatever you
want.
Gareth
On Sun, 21 Sep 2003, Hieu Bui wrote:
> Hi,
>
> I am using Xerces 2.3.0 and am using the DOMWriter to serialize a DOMNode. I have
> things working so that the node is written to a file however I want the serializer
> function to return the node string to a char * pointer (without writing the temp
> file). Can someone please help out on the function below?
>
> TIA,
>
> --Hieu
>
> int serializeNode(DOMNode * node, char * returnString) {
>
> XMLCh tempStr[10];
> XMLString::transcode("LS", tempStr, 9);
> DOMImplementation * impl =
> DOMImplementationRegistry::getDOMImplementation(tempStr);
> DOMWriter * theSerializer = ((DOMImplementationLS *)impl)->createDOMWriter();
> XMLFormatTarget * myLocalFile = new
> LocalFileFormatTarget("c:\\temp\\test.txt");
>
> // optionally you can set some features on this serializer
> if (theSerializer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent,
> true))
> theSerializer->setFeature(XMLUni::fgDOMWRTDiscardDefaultContent, true);
>
> if (theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
> theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
>
> try {
> // do the serialization through DOMWriter::writeNode(); and write to
> local file
> theSerializer->writeNode(myLocalFile, *node);
> //What I really want to do here is write the node to
> returnString
> }
>
> catch (...) {
> return 0;
> }
>
> theSerializer->release();
>
> delete myLocalFile;
>
> return 1;
> }
>
>
> Need a new email address that people can remember
> Check out the new EudoraMail at
> http://www.eudoramail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
Gareth Reakes, Head of Product Development +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]