Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

SAX vs DOM

  Asked By: Eden    Date: Jun 15    Category: Java    Views: 773
  

I have build a xml interface for a java application. I parse the xml
files using dom parser, get the data and pass it to the java
application. I know that DOM builds a in memory tree of the xml file.
Will this degrade the performance of my application. Will it be
better to use a SAX parser instead?

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Angie Bennett     Answered On: Jun 15

Depends on the size of your file. If you have a large
file, it will. In any case, SAX is more efficient but
not appropriate in many cases. Have you considered
JDOM?

 
Answer #2    Answered By: Ray Lawrence     Answered On: Jun 15

Depends on the size of your file. I highly recommend you SAX to parse
XML in Java

I've been building application  to read XML files, i was using JDOM
which was fine for small XML file, then when it's a huge one i had
OutOfMemory problems.

Then i changed to SAX, and i have no problems at all. It maybe a
little bit trickier to map the element, especially if it is a very big
XML file  with dupicates element names. But it's definitely worth it.

Alot more efficient than DOM, for sure.

 
Answer #3    Answered By: Chad Bradley     Answered On: Jun 15

Currently i'm trying to write and read XML file
using java  and i'm using SAX parser. I need help in
two things,
1) How can i travel through the nodes of the the XML
file.
2) How can i write attributes in XML tags.
for example <Name sex="male">......</Name>

 
Didn't find what you were looking for? Find more on SAX vs DOM Or get search suggestion and latest updates.




Tagged: