DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: XML Parsing performance question

  1. #1
    Join Date
    Mar 2009

    XML Parsing performance question

    Hello everyone,

    I am a student trying to work with the various Java APIs for parsing XML. Being new to the area, I have some basic questions as I study and implement these methods.I did some research to find answers to my questions, but could not find answers to some of them. I hope I will find some answers here. So here are my questions:

    - SAX parsing is said to be very memory efficient when compared to DOM. But SAX still requires some memory. Why does it need this memory?

    -Also SAX allows us to terminate when our required criterion is met. Does this mean that the rest of the document is not parsed to check for well-formedness/ validity? Because, as I understand it, the SAX parser steps throught the XML document, generating events when significant data is encountered. So if we stop when our condition is met, does the parsing also stop?

    - Why does DOM take so much memory?(much more than the actual XML file) Is it because of the object reprsentation of the XML elements/attributes. Does DOM also need the XML file in memory? What does in-memory tree representation of an XML file actually mean?

    - If we are parsing an XML file with a Schema, does DOM need to parse the Schema as well and create an in-memory reprsentation?

    - How do the memory requirements of SAX and StAX differ and why?

    I have observed in working with these methods that DOM takes wayyyyy tooo much memory than the actual XML file. I also have observed that Stax takes little more memory than SAX but less time to parse. Why is that so?

    Any help on these topics will be greatly appreciated. I really need help on these. Thanks a lot in advance.

  2. #2
    Join Date
    Dec 2007

    re: xml perfomrance issues

    SAX is performance efficient because it doesn't require a tree-like structure to reside in memory...

    In SAX parsing, you can throw exceptions to get out the parsing routine

    DOM takes memory because it builds a in-memory tree (5~10x) the size of XML..

    sax and STAX have similar memory requirement

    YOu may also want to try vtd-xml whch is a lot faster than SAX and DOM...

Similar Threads

  1. question on XML schema
    By associates in forum XML
    Replies: 0
    Last Post: 10-13-2009, 01:27 AM
  2. Parsing an XML document using SAX API
    By river22_34 in forum XML
    Replies: 3
    Last Post: 02-03-2008, 06:12 AM
  3. Parsing XML - How to differ between XML / DTD
    By Volker Held in forum Java
    Replies: 1
    Last Post: 06-26-2002, 07:25 AM
  4. Parsing question
    By Neil in forum XML
    Replies: 0
    Last Post: 03-15-2002, 09:42 AM
  5. XML DOM Programming Question
    By Bryan Murphy in forum Java
    Replies: 0
    Last Post: 07-13-2000, 03:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center