XML:
Why is XML such an important development? (XML)
It removes two constraints which were holding back Web developments:
1. Dependence on a single, inflexible document type (HTML) which was being much abused for tasks it was never designed for;
2. The complexity of full SGML, whose syntax allows many powerful but hard-to-program options.
* XML allows the flexible development of user-defined document types. It provides a robust, non-proprietary, persistent, and verifiable file format for the storage and transmission of text and data both on and off the Web; and it removes the more complex options of SGML, making it easier to program for.
*(javax.xml.parsers.*) *(org.xml.sax.*) *(javax.xml.parsers.SAXParser) *(javax.xml.parsers.DocumentBuilder) -
*(XML Introduction) *(Using the SAX API) *(Using the DOM API)
*(TUTOR: J2EE Home) *(J2EE: Distributed Multitiered Applications.)
SAX requires much less memory than DOM, because SAX does not construct an internal representation (tree structure) of the XML data, as a DOM does. Instead, SAX simply sends data to the application as it is read; your application can then do whatever it wants to do with the data it sees.
*(EXAMPLE: Echoing an XML File with the SAX Parser.) *(Parsing with a DTD.) -
SAX: (Simple API for XML) Serial Access Protocol. (Tutor)
We can think of this standard as the "serial access" protocol for XML. This is the fast-to-execute mechanism you would use to read and write XML data in a server.
DOM (Document Object Model) Random Access Protocol.
The Document Object Model protocol converts an XML document into a collection of objects in your program. We can then manipulate the object model in any way that makes sense. This mechanism is also known as the "random access" protocol, because you can visit any part of the data at any time. We can then modify the data, remove it, or insert new data.
Difference between SAX and DOM parser
DOM parsers are Object based and SAX parsers are event based
DOM parsers creates Tree in the memory whereas SAX parser does not and hence it is faster than DOM
DOM parser are useful when we have to modify the XML, with SAX parser you cannot modify the xml, it is read only.
No comments:
Post a Comment