-
attlistDeclHandler :function
-
This property holds a callback function with the following parameters: elname(String), attname(String), att_type(String), dflt(String) and isrequired(Integer).
Type:
Example
parser.attlistDeclHandler = function(elname, attname, att_type, dflt, isrequired) {
// do some thing
}
-
characterDataHandler :function
-
This property holds a callback function with one parameter: s(String).
Type:
Example
parser.characterDataHandler = function(s) {
// do some thing
}
-
-
This property holds a callback function with one parameter: data(String).
Type:
Example
parser.commentHandler = function(data) {
// do some thing
}
-
currentByteIndex :Integer
-
This property holds the current byte index of the parser
Type:
-
currentColumnNumber :Integer
-
This property holds the current column position of the parser
Type:
-
currentLineNumber :Integer
-
This property holds the current line position of the parser
Type:
-
endCDataSectionHandler :function
-
This property holds a callback function with no parameters.
Type:
Example
parser.endCDataSectionHandler = function() {
// do some thing
}
-
endDoctypeDeclHandler :function
-
This property holds a callback function with no parameters.
Type:
Example
parser.endDoctypeDeclHandler = function() {
// do some thing
}
-
endElementHandler :function
-
This property holds a callback function with one parameter: name(String).
Type:
Example
parser.endElementHandler = function(name) {
// do some thing
}
-
endNameSpaceDeclHandler :function
-
This property holds a callback function with one parameter: prefix(String).
Type:
Example
parser.endNameSpaceDeclHandler = function(prefix) {
// do some thing
}
-
entityDeclHandler :function
-
This property holds a callback function with seven parameters: entityName(String), is_parameter_entity(Integer), value(String), systemId(String), publicId(String) and notationName(String).
NOTE: During parsing it is the application's responsibility to prevent large number of multiple XML entity expansions.
Type:
Example
parser.entityDeclHandler = function(entityName, is_parameter_entity, value, systemId, publicId, notationName) {
// do some thing
}
-
externalEntityRefHandler :function
-
This property holds a callback function with four parameters: context(String), systemId(String) and publicId(String).
Type:
Example
parser.externalEntityRefHandler = function(context, systemId, publicId) {
// do some thing
}
-
notationDeclHandler :function
-
This property holds a callback function with four parameters: notationName(String), systemId(String) and publicId(String).
Type:
Example
parser.notationDeclHandler = function(notationName, systemId, publicId) {
// do some thing
}
-
processingInstructionHandler :function
-
This property holds a callback function with two parameters: target(String) and data(String).
Type:
Example
parser.processingInstructionHandler = function(target, data) {
// do some thing
}
-
startCDataSectionHandler :function
-
This property holds a callback function with no parameters.
Type:
Example
parser.startCDataSectionHandler = function() {
// do some thing
}
-
startDoctypeDeclHandler :function
-
This property holds a callback function with four parameters: doctypeName(String), sysid(String), pubid(String) and has_internal_subset(Integer).
Type:
Example
parser.startDoctypeDeclHandler = function(doctypeName, sysid, pubid, has_internal_subset) {
// do some thing
}
-
startElementHandler :function
-
This property holds a callback function with two parameters: name(String) and atts(Object).
atts contains key:value pairs of the attributes.
Type:
Example
parser.startElementHandler = function(name, atts) {
// do some thing
}
-
startNameSpaceDeclHandler :function
-
This property holds a callback function with two parameters: prefix(String) and uri(String).
Type:
Example
parser.startNameSpaceDeclHandler = function(prefix, uri) {
// do some thing
}
-
xmlDeclHandler :function
-
This property holds a callback function with three parameters: version(String), encoding(String), standalone(Integer).
Type:
Example
parser.xmlDeclHandler = function(version, encoding, standalone) {
// do some thing
}
-
parse(xml)
-
This method parses the xmlString.
Parameters:
Name |
Type |
Description |
xml |
String
|
data that should be parsed |
Throws:
Throws an error if there was a problem during parsing or
the parser was stopped without the possibility of resuming
Example
var xmlString = //Some xml
var parser = new $.util.SAXParser()
//... set handlers
parser.parse(xmlString);
-
parse(xml, encoding)
-
This method parses the xmlArrayBuffer.
Parameters:
Name |
Type |
Argument |
Description |
xml |
ArrayBuffer
|
|
data that should be parsed |
encoding |
String
|
<optional>
|
supported encodings are UTF-8, UTF-16 and US-ASCII. The default is UTF-8. |
Throws:
Throws an error if there was a problem during parsing or
the parser was stopped without the possibility of resuming
Example
var xmlArrayBuffer = //Some xml
var parser = new $.util.SAXParser()
//... set handlers
parser.parse(xmlArrayBuffer);
-
parse(xml, encoding)
-
This method parses the content of a $.web.Body object.
Parameters:
Name |
Type |
Argument |
Description |
xml |
$.web.Body
|
|
data that should be parsed. The body should contain the XML. Otherwise the parser throws an error. |
encoding |
String
|
<optional>
|
supported encodings are UTF-8, UTF-16 and US-ASCII. The default is UTF-8. |
Throws:
Throws an error if there was a problem during parsing or
the parser was stopped without the possibility of resuming
Example
var body = $.request.body
var parser = new $.util.SAXParser()
//... set handlers
parser.parse(body);
-
reset()
-
This method resets the parser.
Example
var parser = new $.util.SAXParser()
// ...
parser.parse(xmlString1);
parser.reset();
parser.parse(xmlString2);
-
resume()
-
This method resumes the parser. It should not be called from a callback function.
Example
var parser = new $.util.SAXParser()
parser.startElementHandler = function(name, atts) {
//... some logic here
parser.stop(true);
//...
}
parser.parse(xmlString);
parser.startElementHandler = function(name, atts) {
//... some other logic here
}
parser.resume();
-
stop(isResumable)
-
This method stops the parser. It should be called from a callback function.
Parameters:
Name |
Type |
Description |
isResumable |
Boolean
|
if true than when called the parser is suspended and can be resumed.
If false the parser cannot be resumed and an error is thrown. |
Throws:
Throws an error if isResumable = false
Example
var parser = new $.util.SAXParser()
parser.startElementHandler = function(name, atts) {
//... some logic here
parser.stop(false);
//...
}
try {
parser.parse(xmlString);
} catch(error) {
// handle parser.stop(false) error
}