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.
Properties
Section titled “Properties”didEndDocument
Section titled “didEndDocument”Function called when the parser ends parsing a document.
didEndDocument: fn()When the parser calls the function, it has successfully completed parsing the document.
didEndElement
Section titled “didEndElement”Function called when ended parsing an element.
didEndElement: fn()Called by the parser when it encounters an end tag for an element. The function takes the element name as a parameter.
didStartDocument
Section titled “didStartDocument”Function called when the parser begins parsing a document.
didStartDocument: fn()didStartElement
Section titled “didStartElement”Function called when starting to parse an element.
didStartElement: fn(string, {string: string})Called by the parser when it encounters a start tag for an element. The function takes the element name as a parameter as well as a key value pair containing all the attributes associated with the element.
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.
foundCharacters
Section titled “foundCharacters”Function called when the parser finds characters of an element.
foundCharacters: fn()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.
parseErrorOccurred
Section titled “parseErrorOccurred”Function called when the parser encounters an error.
parseErrorOccurred: fn()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.
string
Section titled “string”XML string to be parsed.
string: stringMethods
Section titled “Methods”
new XMLParser(string)
Section titled “new XMLParser(string)”Constructs an XMLParser.
new XMLParser(string: string)Constructs an event driven XML parser. It does not do any parsing on its own and therefore the callback functions must be set before starting to parse.
Parameters
Section titled “Parameters”string string
XML string to be parsed.
parse()
Section titled “parse()”Starts parsing.
parse(): boolBefore calling this function you should ensure that the parser is correctly configured, i.e. the necessary callback functions should be set.
Return value
Section titled “Return value”bool
Whether parsing was successfully started.