Blame doc/interface.html

Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
<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 Service a31ea6
TD {font-family: Verdana,Arial,Helvetica}
Packit Service a31ea6
BODY {font-family: Verdana,Arial,Helvetica; margin-top: 2em; margin-left: 0em; margin-right: 0em}
Packit Service a31ea6
H1 {font-family: Verdana,Arial,Helvetica}
Packit Service a31ea6
H2 {font-family: Verdana,Arial,Helvetica}
Packit Service a31ea6
H3 {font-family: Verdana,Arial,Helvetica}
Packit Service a31ea6
A:link, A:visited, A:active { text-decoration: underline }
Packit Service a31ea6
</style><title>The SAX interface</title></head><body bgcolor="#8b7765" text="#000000" link="#a06060" vlink="#000000">
Action against software patentsGnome2 LogoW3C LogoRed Hat Logo
Made with Libxml2 Logo

The XML C parser and toolkit of Gnome

The 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 Service a31ea6
memory. In that case (and if you don't expect to save back the XML document
Packit Service a31ea6
loaded using libxml), it's better to use the SAX interface of libxml. SAX is
Packit Service a31ea6
a callback-based interface to the parser. Before parsing,
Packit Service a31ea6
the application layer registers a customized set of callbacks which are
Packit Service a31ea6
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 Service a31ea6
libxml, see the nice
Packit Service a31ea6
documentation.written by James
Packit Service a31ea6
Henstridge.

You can debug the SAX behaviour by using the testSAX

Packit Service a31ea6
program located in the gnome-xml module (it's usually not shipped in the
Packit Service a31ea6
binary packages of libxml, but you can find it in the tar source
Packit Service a31ea6
distribution). Here is the sequence of callbacks that would be reported by
Packit Service a31ea6
testSAX when parsing the example XML document shown earlier:

SAX.setDocumentLocator()
Packit Service a31ea6
SAX.startDocument()
Packit Service a31ea6
SAX.getEntity(amp)
Packit Service a31ea6
SAX.startElement(EXAMPLE, prop1='gnome is great', prop2='&amp; linux too')
Packit Service a31ea6
SAX.characters(   , 3)
Packit Service a31ea6
SAX.startElement(head)
Packit Service a31ea6
SAX.characters(    , 4)
Packit Service a31ea6
SAX.startElement(title)
Packit Service a31ea6
SAX.characters(Welcome to Gnome, 16)
Packit Service a31ea6
SAX.endElement(title)
Packit Service a31ea6
SAX.characters(   , 3)
Packit Service a31ea6
SAX.endElement(head)
Packit Service a31ea6
SAX.characters(   , 3)
Packit Service a31ea6
SAX.startElement(chapter)
Packit Service a31ea6
SAX.characters(    , 4)
Packit Service a31ea6
SAX.startElement(title)
Packit Service a31ea6
SAX.characters(The Linux adventure, 19)
Packit Service a31ea6
SAX.endElement(title)
Packit Service a31ea6
SAX.characters(    , 4)
Packit Service a31ea6
SAX.startElement(p)
Packit Service a31ea6
SAX.characters(bla bla bla ..., 15)
Packit Service a31ea6
SAX.endElement(p)
Packit Service a31ea6
SAX.characters(    , 4)
Packit Service a31ea6
SAX.startElement(image, href='linus.gif')
Packit Service a31ea6
SAX.endElement(image)
Packit Service a31ea6
SAX.characters(    , 4)
Packit Service a31ea6
SAX.startElement(p)
Packit Service a31ea6
SAX.characters(..., 3)
Packit Service a31ea6
SAX.endElement(p)
Packit Service a31ea6
SAX.characters(   , 3)
Packit Service a31ea6
SAX.endElement(chapter)
Packit Service a31ea6
SAX.characters( , 1)
Packit Service a31ea6
SAX.endElement(EXAMPLE)
Packit Service a31ea6
SAX.endDocument()

Most of the other interfaces of libxml2 are based on the DOM tree-building

Packit Service a31ea6
facility, so nearly everything up to the end of this document presupposes the
Packit Service a31ea6
use of the standard DOM tree build. Note that the DOM tree itself is built by
Packit Service a31ea6
a set of registered default callbacks, without internal specific
Packit Service a31ea6
interface.

Daniel Veillard

</body></html>