This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes SAX or DOM to read XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "SAX or DOM to read XML" Watch "SAX or DOM to read XML" New topic
Author

SAX or DOM to read XML

John King
Ranch Hand

Joined: Aug 27, 2002
Posts: 165
I need to read a xml string and create an object to
represent the xml. Which one of sax and dom is better?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
If you want an object in memory that represents an XML document, you have to use DOM or a related technology. SAX parsers simply scan once through a document and it is up to the programmer to hang on to the data needed.
Bill
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Here's a simple method for parsing a string into a DOM object. It's up to you from that point forward to create your specific object based on that DOM tree.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SAX or DOM to read XML
 
Similar Threads
So how do I start parsing XML with URLConnection?
how to compare two xml files?
XML Parser
Class Path
DOM vs SAX