Download presentation
Presentation is loading. Please wait.
Published byChastity Chrystal Tyler Modified over 9 years ago
1
SAX2 and DOM2 Kanda Runapongsa (krunapon@kku.ac.th)krunapon@kku.ac.th Dept. of Computer Engineering Khon Kaen University
2
168493: XML and Web Services (II/2546) 2 SAX An event-based architecture for processing XML documents To use SAX, you create a class that implements one of the SAX listener interfaces and register an instance of that class with a SAX parser at runtime
3
168493: XML and Web Services (II/2546) 3 How Does SAX Work? A SAX parser reads an XML document from a data stream, sequentially from beginning to end As it reads the stream, the SAX parser sends event to the listener object that you registered The parser invokes callback methods on the listener object as it encounters different parts of the XML document
4
168493: XML and Web Services (II/2546) 4 How Does SAX Work? (Cont.) At the start of the XML document, the parser invokes the listener’s startDocument() method When it reads the start tag of an element, it invokes the listeners’ startElement() method When it reads the end tag of an element, it invokes the listeners’ endElement() method
5
168493: XML and Web Services (II/2546) 5 DOM A set of interfaces and classes used to model XML documents as a tree of objects called nodes You use the DOM programming API to examine existing XML documents, or to create new nodes or to remove existing nodes
6
168493: XML and Web Services (II/2546) 6 How Does DOM Work? When an implementation of DOM parses an XML document, it reads the XML text from some source Then it builds an object graph, called a tree, that mirrors the structure of the XML document
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.