|
Packit |
423ecb |
|
|
Packit |
423ecb |
|
|
Packit |
423ecb |
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><link rel="SHORTCUT ICON" href="/favicon.ico" /><style type="text/css">
|
|
Packit |
423ecb |
TD {font-family: Verdana,Arial,Helvetica}
|
|
Packit |
423ecb |
BODY {font-family: Verdana,Arial,Helvetica; margin-top: 2em; margin-left: 0em; margin-right: 0em}
|
|
Packit |
423ecb |
H1 {font-family: Verdana,Arial,Helvetica}
|
|
Packit |
423ecb |
H2 {font-family: Verdana,Arial,Helvetica}
|
|
Packit |
423ecb |
H3 {font-family: Verdana,Arial,Helvetica}
|
|
Packit |
423ecb |
A:link, A:visited, A:active { text-decoration: underline }
|
|
Packit |
423ecb |
</style><title>The SAX interface</title></head><body bgcolor="#8b7765" text="#000000" link="#a06060" vlink="#000000"> | | The XML C parser and toolkit of GnomeThe SAX interface |
|
|
<center>Developer Menu</center> | <form action="search.php" enctype="application/x-www-form-urlencoded" method="get"><input name="query" type="text" size="20" value="" /><input name="submit" type="submit" value="Search ..." /></form> |
<center>API Indexes</center> | |
<center>Related links</center> | |
|
| Sometimes the DOM tree output is just too large to fit reasonably into |
|
|
|
|
|
|
Packit |
423ecb |
memory. In that case (and if you don't expect to save back the XML document
|
|
Packit |
423ecb |
loaded using libxml), it's better to use the SAX interface of libxml. SAX is
|
|
Packit |
423ecb |
a callback-based interface to the parser. Before parsing,
|
|
Packit |
423ecb |
the application layer registers a customized set of callbacks which are
|
|
Packit |
423ecb |
called by the library as it progresses through the XML input.To get more detailed step-by-step guidance on using the SAX interface of
|
|
Packit |
423ecb |
libxml, see the nice
|
|
Packit |
423ecb |
documentation.written by James
|
|
Packit |
423ecb |
Henstridge.You can debug the SAX behaviour by using the testSAX
|
|
Packit |
423ecb |
program located in the gnome-xml module (it's usually not shipped in the
|
|
Packit |
423ecb |
binary packages of libxml, but you can find it in the tar source
|
|
Packit |
423ecb |
distribution). Here is the sequence of callbacks that would be reported by
|
|
Packit |
423ecb |
testSAX when parsing the example XML document shown earlier:SAX.setDocumentLocator()
|
|
Packit |
423ecb |
SAX.startDocument()
|
|
Packit |
423ecb |
SAX.getEntity(amp)
|
|
Packit |
423ecb |
SAX.startElement(EXAMPLE, prop1='gnome is great', prop2='& linux too')
|
|
Packit |
423ecb |
SAX.characters( , 3)
|
|
Packit |
423ecb |
SAX.startElement(head)
|
|
Packit |
423ecb |
SAX.characters( , 4)
|
|
Packit |
423ecb |
SAX.startElement(title)
|
|
Packit |
423ecb |
SAX.characters(Welcome to Gnome, 16)
|
|
Packit |
423ecb |
SAX.endElement(title)
|
|
Packit |
423ecb |
SAX.characters( , 3)
|
|
Packit |
423ecb |
SAX.endElement(head)
|
|
Packit |
423ecb |
SAX.characters( , 3)
|
|
Packit |
423ecb |
SAX.startElement(chapter)
|
|
Packit |
423ecb |
SAX.characters( , 4)
|
|
Packit |
423ecb |
SAX.startElement(title)
|
|
Packit |
423ecb |
SAX.characters(The Linux adventure, 19)
|
|
Packit |
423ecb |
SAX.endElement(title)
|
|
Packit |
423ecb |
SAX.characters( , 4)
|
|
Packit |
423ecb |
SAX.startElement(p)
|
|
Packit |
423ecb |
SAX.characters(bla bla bla ..., 15)
|
|
Packit |
423ecb |
SAX.endElement(p)
|
|
Packit |
423ecb |
SAX.characters( , 4)
|
|
Packit |
423ecb |
SAX.startElement(image, href='linus.gif')
|
|
Packit |
423ecb |
SAX.endElement(image)
|
|
Packit |
423ecb |
SAX.characters( , 4)
|
|
Packit |
423ecb |
SAX.startElement(p)
|
|
Packit |
423ecb |
SAX.characters(..., 3)
|
|
Packit |
423ecb |
SAX.endElement(p)
|
|
Packit |
423ecb |
SAX.characters( , 3)
|
|
Packit |
423ecb |
SAX.endElement(chapter)
|
|
Packit |
423ecb |
SAX.characters( , 1)
|
|
Packit |
423ecb |
SAX.endElement(EXAMPLE)
|
|
Packit |
423ecb |
SAX.endDocument()Most of the other interfaces of libxml2 are based on the DOM tree-building
|
|
Packit |
423ecb |
facility, so nearly everything up to the end of this document presupposes the
|
|
Packit |
423ecb |
use of the standard DOM tree build. Note that the DOM tree itself is built by
|
|
Packit |
423ecb |
a set of registered default callbacks, without internal specific
|
|
Packit |
423ecb |
interface.Daniel Veillard </body></html>
|