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;
I would expect so, yes. Have you tried it?
Of course, you're still _reading_ the whole file. Otherwise, how would
your call to StrLen give any meaningful answer? You're more interested
in just stopping before the whole file is parsed.
> The progress bar calculation don't seem to work properly. to How can I
> make the progress bar show the remaining reading execution?
I suspect that's exactly what it's doing already. But how much remains
to be read at the time that line runs?
If you don't know what your code is doing, it's frequently an easy task
to step through the code with the debugger. You can watch your program
run line by line. You have a loop; how many times does it execute?
The previous statement is indented as though it's inside the loop, but
it really isn't. The next line indented similarly. Indentation is key to
having human-readable code.
> Parser.Free;
> end;
--
Rob
Jens