Le 18/06/2013 15:42, Marcos Douglas a écrit :
On Tue, Jun 18, 2013 at 10:32 AM, Michael Van Canneyt
<mich...@freepascal.org> wrote:

On Tue, 18 Jun 2013, Marcos Douglas wrote:

On Tue, Jun 18, 2013 at 9:39 AM, Antonio Fortuny
<a.fort...@sitasoftware.lu> wrote:


Le 18/06/2013 14:35, Marcos Douglas a écrit :

Hi,

I need to save some huge XML files in HD.
Today I call WriteXMLFile(Doc, AFileName) but I have XML with 5G, 10G..
30G...

What the best way to save "line by line"?

Append chuncks of lines to a TFileStream until source XML file is
exhausted

But I'm using TXMLDocument class to make the XML.

For each line (log) I do this:
(doesn't matter the information in Par variable)

procedure TXMLLogger.Log;
var
 I: Integer;
 No: TDOMElement;
 Par: TParam;
begin
 No := FDoc.CreateElement('line');
 for I := 0 to FParams.Count-1 do
 begin
   Par := FParams.Items[I];
   TDOMElement(No).SetAttribute(Par.Name, Par.AsString);
 end;
 FRootNode.AppendChild(No);

 FParams.Clear;
end;

At the end, I do some like:
procedure TXMLLogger.Finish;
var
 No: TDOMElement;
begin
 No := FDoc.CreateElement('finish');
 TDOMElement(No).SetAttribute('dh', FmtDateTime(Now));
 FRootNode.AppendChild(No);
end;

And the application call:
procedure TXMLLogger.SaveToFile(const AFileName: string);
begin
 WriteXMLFile(FDoc, AFileName);
end;

So, there is a way to use TXMLDocument but save line by line more faster?

No. The writer already uses a fixed buffer. Your problem is the use of
TXMLDocument.
Ideas? Maybe do what Antonio Fortuny said before?
Yep, a text file: assign, reset, append, close. I use an own build logger facility (for historical reasons) but I wonder whether Lazarus (or FPC) does not have such a logger component.

Simply put: logging to XML (worse: using DOM) is a VERY bad idea.
Well, this is a request of my client. Other process will read this XML.

Thanks,
Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

--
Sita
                Software
Antonio Fortuny
Senior Software engineer

220, avenue de la Liberté
L-4602 Niederkorn
Tel.: +352 58 00 93 - 93
www.sitasoftware.lu
Your IT Partner
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to