Thread View: borland.public.delphi.xml
1 messages
1 total messages
Started by fokrogh
Thu, 11 Sep 2008 14:59
Newbie: How to speed up a simple xml parsing task?
Author: fokrogh
Date: Thu, 11 Sep 2008 14:59
Date: Thu, 11 Sep 2008 14:59
59 lines
2845 bytes
2845 bytes
I have written this simple code to retrieve some attribute values.
The
attributes are all located in the beginning of each xml file.
However,
it takes VERY long time before the first attribute value is found
(depending on the file size).
Is there a way to speed up the the reading of the xml file - is it
possible to stop the reading execution before the whole file is read?
The progress bar calculation don't seem to work properly. to How can
I
make the progress bar show the remaining reading execution?
Regards
Frank Krogh
________________________________
procedure ParseThisFile (myXmlFile: string;fileNumber:integer);
var
Parser: TXmlParser;
XmlFileName, foundValue: string;
DocSize : integer;
begin
Parser := TXmlParser.Create;
Parser.Normalize := True;
Parser.loadfromfile (myXmlFile);
DocSize := StrLen (Parser.DocBuffer);
Parser.StartScan;
While Parser.Scan do
Case Parser.CurPartType of
ptStartTag: begin
foundValue := parser.curattr.value('companyID');
if trim(foundValue) <> '' then
Form1.StringGrid1.cells[1,fileNumber + 1]:= foundValue;
foundValue :=
parser.curattr.value('businessType');
if trim(foundValue) <> '' then
Form1.StringGrid1.cells[2,fileNumber + 1]:= foundValue;
foundValue := parser.curattr.value('State');
if trim(foundValue) <> '' then
Form1.StringGrid1.cells[3,fileNumber + 1]:= foundValue;
end;
End; {case}
Form1.ProgressBar1.Position := Trunc(( Parser.CurFinal -
Parser.DocBuffer) / DocSize * 100.0);
Parser.Free;
end;
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads