CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2002
    Location
    Chandigarh, India
    Posts
    91

    DOM Vs SAX2

    Hi Everybody,
    I have two applications which are used to parse XML file. The first one is using DOM object to parse it and the second one is using SAX2 to parse the file. The same file is parsed for both applications one by one. The DOM parser application takes much lesser time with more memory consumption as compared to SAX parser.
    If DOM consumes much more memory as compared to SAX2, then why SAX2 parser is much slower than DOM parser.
    Last edited by shitij; May 15th, 2004 at 04:46 AM.

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626
    You answered your own question.

    DOM is faster because it uses more memory. SAX2 is slower because it goes out of it's way to do it's job in as few memory as possible.

    The 'problem' here is that you're probably just reading small XML files. If that's all you'll ever need to do, then DOM is probably a better way to go.

    If however you need to be able to parse large/huge XML files (possibly larger than available memory), then DOM probably won't be able to parse them while SAX2 will.

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

Featured