Difference Between Similar Terms and Objects

Difference Between SAX and DOM

xmlSAX vs. DOM

Simple API for XML (also known as SAX) is a serial access parser API for XML (that is an API that obtains data, and analyses the text from that particular document in dynamically created web pages, or web pages with interactive content). It acts as one of the more popular alternatives to the Document Object Model (also known as DOM).

DOM is a convention that is completely independent of a specific language. It is a convention that is compatible with multiple platforms. It is used to represent and interact with objects in HTML, XML, and XHTML documents. Within the syntax of the language a DOM uses, many aspects of the DOM can be addressed and manipulated.

A SAX parser functions as what is known as a stream parser (which means it obtains and analyses text that is streaming from its location). It contains an event driven API (that is an API that is dependent on events that occur within a certain environment). The user has the control to define the number of callback methods (that is methods that trace back to the source of the requested data). These methods will be called when events occur during the act of parsing. There are four main events that could occur during parsing: XML Test nodes, XML Element nodes, XML Processing Instructions, and XML Comments. When these XML features are encountered, events are put in to play. Events also occur when these features have reached their end. As such, SAX is unidirectional (meaning moving in one direction), and data that was parsed previously cannot be re-read without starting the parsing operation back up.

DOM is best put into play for applications wherein the document must be repeatedly accessed, or if the document happens to be out of its sequence order. If the application is in a strict sequence, and one-pass (that means unable to be accessed without beginning a parsing sequence again), then SAX comes into play. Most web browsers do not make use of DOM for the purpose of rendering HTML documents. However, DOM is a necessity for JavaScript scripts that wish to dynamically analyse or change anything pertaining to a web page. Essentially, the DOM is the way in which JavaScript can visualise the HTML page and browser state in which it is contained (i.e. exploring its environment).

Summary:

1. SAX is a serial access parser API for dynamic web pages; DOM is a convention without a language or a dependency on language.

2. A SAX parser allows the user to control the number of callback methods; DOM functions independently in order to allow JavaScript scripts to access, change, or analyse anything pertaining to dynamic web pages, allowing the JavaScript to ‘physically’ explore its environment.

Sharing is caring!


Search DifferenceBetween.net :




Email This Post Email This Post : If you like this article or our site. Please spread the word. Share it with your friends/family.


Leave a Response

Please note: comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Articles on DifferenceBetween.net are general information, and are not intended to substitute for professional advice. The information is "AS IS", "WITH ALL FAULTS". User assumes all risk of use, damage, or injury. You agree that we have no liability for any damages.


See more about : , ,
Protected by Copyscape Plagiarism Finder