The library includes minimal numbers of functions of the Expat XML parser. If an XML file contains non-ASCII characters, it should be processed line by line with each line encoded as UTF-8 string.
Function | Parameter Type | Remark |
expat() | Creates and returns an object to handle xml stream using the EXPAT library. | |
.version() | Returns EXPAT version string. | |
.callback(start, end, data) | string, string, string | Sets callback functions to handle xml stream produced by the EXPAT object. For the start callback, if the first argument is an integer (indicating depth level), the second will be a xml tag name; otherwise the first will be the key and the second will be the value of a xml attribute. The end callback function should handle one argument as a closing xml tag. The data callback function should handle one argument as a string. |
.parse(str) | string | Parses an xml string. |
load("expat.dll"); function f1(a, b) { csv(a, b); } function f2(a) { csv(a); } function f3(a) { csv(a); } xml = expat(); xml.version(); xml.callback("f1", "f2", "f3"); xml.parse("<a>abc<b>ABC</b></a>");