Results 1 to 3 of 3

Thread: [VB6] MSXML DOM vs. SAX Performance

  1. #1

    Thread Starter
    Join Date
    Feb 2006

    [VB6] MSXML DOM vs. SAX Performance

    Demo task:

    Process sample.xml for each <abc:Person/> node.

    • LicenseNo
    • Company
    • Language from xyz:languageCode attribute of xyz:Language
    • Region
    • CountryCode
    • ZipCode
    • City from the xyz:AddressText node with the highest xyz:sequenceNumber attribute

    The sample.xml file is 1.738 MB. It just contains two unique "Person" nodes repeated many times to make including it within the ZIP archive practical.

    Start of the XML data:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <doc xmlns:abc="urn:abc" xmlns:xyz="urn:xyz">
      <xyz:Language xyz:languageCode="en">
          <xyz:Company xyz:languageCode="en">ABC Company Ltd.</xyz:Company>
            <xyz:SequencedAddress xyz:languageCode="en">
              <xyz:AddressText xyz:sequenceNumber="1">The ABC Building</xyz:AddressText>
              <xyz:AddressText xyz:sequenceNumber="2">123 Main Street</xyz:AddressText>
              <xyz:AddressText xyz:sequenceNumber="3">3rd Floor</xyz:AddressText>
              <xyz:AddressText xyz:sequenceNumber="4">Tampa</xyz:AddressText>
              <xyz:Region xyz:RegionCategory="State">FL</xyz:Region>

    See the classics The Joy of SAX: a Visual Basic Sample and SAX, the Simple API for XML.

    Also see SAX2 in Microsoft's legacy documentation site.

    Name:  sshotDOM.png
Views: 318
Size:  3.3 KB

    Name:  sshotSAX.png
Views: 291
Size:  3.3 KB

    The attachment contains the input data and those two sample programs. It also has a "SAX batch" program that writes the rows to a disk file, a "SAX batch MDB" that writes the extracted data as rows in a Jet MDB table, and a "SAX separate class" program that is a little slower than the "SAX" program but reflects how you'd probably normally use SAX instead of implementing MSXML2.IVBSAXContentHandler inline within a Form.


    A version of Windows with MSXML version 6.0 however with small modifications MSXML 3.0 can be used instead but it is a bit slower (like taking twice the time in the DOM sample).
    Attached Files Attached Files
    Last edited by dilettante; Nov 6th, 2018 at 02:19 PM.

  2. #2

    Thread Starter
    Join Date
    Feb 2006

    Re: [VB6] MSXML DOM vs. SAX Performance

    Note that SAX works best for scenarios where you can extract data in a simple forward pass over the XML document.

    When you require a "sense of time and space" as in the case of fetching "City" in the demo programs you will have to accumulate some state as you go. When processing "early" elements requires knowledge of "late" elements you can make two passes, but if the amount of accumlated state required is large then you might want to drop back to using DOM.

    In addition to being slower DOM will use a lot more memory. If that is a consideration such as server-side code handling many client requests (say, VB6 DLLs behind ASP pages) SAX can be a better choice as long as it fits your situation.

    Often you'll see SAX2 in Microsoft documentation because the older SAX version 1 is almost never used by anyone and hasn't for a very long time. I'm not sure that MSXML ever had a SAX version 1 implementation.

  3. #3
    Join Date
    Jun 2015

    Re: [VB6] MSXML DOM vs. SAX Performance

    Thanks for posting! Not sure that anyone else posts SAX examples.
    This is perfect for converting CIM XML representations of a power system (multiple GB) into a relational DB.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width