SAX2 and DOM2 - PowerPoint PPT Presentation

About This Presentation
Title:

SAX2 and DOM2

Description:

SAX2 and DOM2 Kanda Runapongsa (krunapon_at_kku.ac.th) Dept. of Computer Engineering Khon Kaen University SAX An event-based architecture for processing XML documents To ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 7
Provided by: KandaRun
Category:
Tags: dom2 | mirrors | sax2

less

Transcript and Presenter's Notes

Title: SAX2 and DOM2


1
SAX2 and DOM2
  • Kanda Runapongsa
  • (krunapon_at_kku.ac.th)
  • Dept. of Computer Engineering
  • Khon Kaen University

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
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
How Does SAX Work? (Cont.)
  • At the start of the XML document, the parser
    invokes the listeners 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
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
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
Write a Comment
User Comments (0)
About PowerShow.com