X M L

A p p lic a t io n

S A X A P I

X M L P a r s e r

X M L

D o c u m e n t

Figure 3-3 SAX application components

To understand how an event-based API can work, consider the sample document in Example 3-1.

Example 3-1 Sample XML document

<?xml version="1.0" encoding="UTF-8"?> <Customer>

<name>Mary Smith</name> <membership>10001</membership>

</Customer>

An event-based interface will break the structure of this document down into a series of linear events, such as those shown in Example 3-2.

Example 3-2 Sample event breakdown

start document

start element: Customer

start element: name

characters: Mary Smith

end element: name

start element: membership

characters: 10001

end element: membership

end element: Customer end document

Chapter 3. Processing XML 59

Page 75
Image 75
IBM Version 5 manual Example 3-1 Sample XML document, Example 3-2 Sample event breakdown