Tuesday, March 13, 2012

What are the frequent interview questions about XML parser? Difference between two xml parsers? when will use what parser?

What are the frequent interview questions about XML parser? Difference between two xml parsers? when will use what parser?
Answer: There are two main parser in SAX and DOM are most popular parser to process the xml file in java.
Read and Write Difference: SAX: This parser can only used for reading the xml document but not manupulating the data in xml document. DOM: This parser can read and manupulate data in xml document.
Sequential Access and Random Access: SAX can be accessed sequentially to process the xml document and DOM can be accessed ramdomly to process the xml document. Call back mechanism and Tree: SAX uses call back mechanism and event stream to process sequentially the large amount of xml data. wheras DOm procees the tree structure of ramdom access of large amount of data.
Information set: SAX doesn't retain all the information comment in xml document but DOM will retain all the comments located in the xml document.
Speed and Memory of both parsers: SAx is much faster than compared to any other parser DOM is slower due to save all the xml data into single memory.

No comments:

Post a Comment