Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Newbie: How to speed up a simple xml parsing task?

19 views
Skip to first unread message

fok...@start.no

unread,
Sep 11, 2008, 10:59:33 AM9/11/08
to
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;


0 new messages