Skip to content

XMLParser

Event driven XML parser.

The XMLParser is an event driven XML parser that calls provided callback functions when it encounters elements to be parsed. It does not iself do any parsing.

didStartDocument

Function called when the parser begins parsing a document.

didStartDocument: fn()

didEndDocument

Function called when the parser ends parsing a document.

The the parser calls the function, it has successfully completed parsing the document.

didEndDocument: fn()

didStartElement

Function called when starting to parse an element.

Called by the parser when it encounters a start tag for an element. The function takes the element name as a parameter. Use this function to update your state and prepare for receiving the characters of the element. After this function is called, the parser will call the foundCharacters callback function with all or parts of the characters of the element.

didStartElement: fn(string)

didEndElement

Function called when ended parsing an element.

Called by the parser when it encounters an end tag for an element. The function takes the element name as a parameter.

didEndElement: fn(string)

foundCharacters

Function called when the parser finds characters of an element.

The parser calls this function with a string whenever it finds characters for the current element. This function may be called several times for a single element.

foundCharacters: fn(string)

parseErrorOccurred

Function called when the parser encounters an error.

The parser will call this function when it encounters a fatal error preventing it from continuing to parse. When the function is called the parsing is stopped.

parseErrorOccurred: fn(string)

string

XML string to be parsed.

string: string

-new XMLParser

Constructs an XMLParser.

Constructs an even driven XML parser. It does not itself do any parsing therfore the callback functions must be set before starting to parse.

new XMLParser(string: string)

-parse

Starts parsing.

Before calling this function you should ensure that the parser is correctly configured, i.e. the necessary callback functions should be set.

parse(): bool