I have just modified the LocalFileFormatTarget to have some buffering.   It
should be faster now.

Tinny
----- Original Message -----
From: "Dave Hoffer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, November 20, 2002 8:04 AM
Subject: RE: How can I write a DOMDocument faster?


Thanks!  This fixed the problem.

-dh

-----Original Message-----
From: Zeid Derhally [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 19, 2002 4:03 PM
To: [EMAIL PROTECTED]
Subject: RE: How can I write a DOMDocument faster?



I'm not sure if it is the same problem I had, but writing the DOM tree
directly to disk is pretty slow, because it writes a few characters at a
time.  I think there is a bug already filed against it.  I'm planning on
working on a fix to this, but just have not had the time.  As a
workaround you can write the DOM tree to memory using the
MemBufFormatTarget class, and then write that buffer to disk.

Here is snippet:


MemBufFormatTarget *myFormTarget = new MemBufFormatTarget();
theSerializer->writeNode(myFormTarget, *doc);
XMLPlatformUtils::writeBufferToFile(xmlFile, myFormTarget->getLen(),
myFormTarget->getRawBuffer());
XMLPlatformUtils::closeFile(xmlFile);
delete myFormTarget;


> -----Original Message-----
> From: Dave Hoffer [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, November 19, 2002 2:58 PM
> To: [EMAIL PROTECTED]
> Subject: How can I write a DOMDocument faster?
>
>
> I am using the following code to write a DOMDocument to disk.
>  It is taking a very long time to write (a 13KB file is
> taking about 2.5 minutes) and it is driving my hard drive
> crazy (it is constantly doing something).
>
> I obviously am doing something wrong here, can someone point
> me in the right direction?
>
> LocalFileFormatTarget* pXMLFormatTarget;
>
> DOMImplementation* pDOMImplementation =
> DOMImplementationRegistry::getDOMImplementation(L"LS");
> if (!pDOMImplementation)
> return false;
>
> DOMWriter* pDOMWriter =
> ((DOMImplementationLS*)pDOMImplementation)->createDOMWriter();
> if (!pDOMWriter)
> return false;
>
> pXMLFormatTarget = new LocalFileFormatTarget( m_strTargetSpec );
>
> if (!(pDOMWriter->writeNode(pXMLFormatTarget, *pDomDocument)))
> return false;
>
> pDOMWriter->release();
>
> -dh
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to