What is the fastest XML Parser available for Delphi?

前端 未结 5 1650
梦谈多话
梦谈多话 2020-12-04 14:46

We have reasonably large XML strings which we currently parse using MSXML2

I have just tried using MSXML6 hoping for a speed improvement and have got nothing!

<
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 15:26

    some time ago I had to serialize record to XML format; for ex:

     TTest = record
        a : integer;
        b : real; 
     end;
    

    to

        
            value
            value
        

    I used RTTI to recursively navigate through record fields and storing values to XML. I've tried few XML Parsers. I did't need DOM model to create xml, but needed it to load it back.

    XML contained about 310k nodes (10-15MBytes); results presented in table below, there are 6 columns with time in seconds;
    1 - time for creating nodes and write values
    2 - SaveToFile();
    3 = 1 + 2
    4 - LoadFromFile();
    5 - navigate through nodes and read values
    6 = 4 + 5
    enter image description here

    MSXML/Xerces/ADOM - are differend vendors for TXMLDocument (DOMVendor)
    JanXML doesn't work with unicode; I fixed some errors, and saved XML, but loading causes AV (or stack overflow, I don't remember);
    manual - means manually writing XML using TStringStream.

    I used Delphi2010, Win7x32, Q8200 CPU/2.3GHz, 4Gb of RAM.

    update: You can download source code for this test (record serialization to XML using RTTI) here http://blog.karelia.pro/teran/files/2012/03/XMLTest.zip All parsers (Omni, Native, Jan) are included (now nodes count in XML is about 270k), sorry there are no comments in code.

提交回复
热议问题