Example of a SAX Parsing Sequence

This is an example of the sequence of callback functions called, for an example string of XML data. Before parsing, these callback functions were set up:

  • cb_startAllElements for start-of-element event type.

  • cb_endAllElements for end-of-element event type.

  • cb_startElement1 for start-of-element, with optional name specified as "elapsedTime."

  • cb_endElement1 for end-of-element, with optional name specified as "elapsedTime."

  • cb_chars for characters event type.

  • cb_allCharacters for characters, with optional setting for characters after elements.

  • cb_fatalError for fatal-error event type.

The example XML string to be parsed is:

<main>startMain<elapsedTime>123</elapsedTime>endMain</main>

This callback sequence results from parsing this XML string:

  • cb_startAllElements for main.

  • cb_chars for startMain.

  • cb_allCharacters for startMain.

  • cb_startAllElements for elapsedTime.

  • cb_startElement1 for elapsedTime.

  • cb_chars for 123.

  • cb_allCharacters for 123.

  • cb_endAllElements for elapsedTime.

  • cb_endElement1 for elapsedTime.

  • cb_allCharacters for endMain.

  • cb_endAllElements for main.

  • cb_fatalError is not called while parsing this example XML string.