pax_global_header 0000666 0000000 0000000 00000000064 13473600530 0014513 g ustar 00root root 0000000 0000000 52 comment=0c14bc27c8085e1b6ea7444b301a2dffa9aeeae8 node-expat-2.3.18/ 0000775 0000000 0000000 00000000000 13473600530 0013652 5 ustar 00root root 0000000 0000000 node-expat-2.3.18/.editorconfig 0000664 0000000 0000000 00000000307 13473600530 0016327 0 ustar 00root root 0000000 0000000 # EditorConfig is awesome: http://EditorConfig.org root = true [*] end_of_line = lf insert_final_newline = true charset = utf-8 trim_trailing_whitespace = true indent_style = space indent_size = 2 node-expat-2.3.18/.gitignore 0000664 0000000 0000000 00000000112 13473600530 0015634 0 ustar 00root root 0000000 0000000 build/ node_modules/ !.editorconfig !.gitignore !.npmignore !.travis.yml node-expat-2.3.18/.npmignore 0000664 0000000 0000000 00000000105 13473600530 0015645 0 ustar 00root root 0000000 0000000 test/ .editorconfig .gitignore .npmignore .travis.yml benchmark.js node-expat-2.3.18/.travis.yml 0000664 0000000 0000000 00000000211 13473600530 0015755 0 ustar 00root root 0000000 0000000 sudo: false dist: trusty language: node_js node_js: - '4' - '6' - '8' - '10' - '12' before_script: npm install -g standard node-expat-2.3.18/LICENSE 0000664 0000000 0000000 00000002041 13473600530 0014654 0 ustar 00root root 0000000 0000000 Copyright (c) 2010 Stephan Maka Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. node-expat-2.3.18/README.md 0000664 0000000 0000000 00000007430 13473600530 0015135 0 ustar 00root root 0000000 0000000 # node-expat [](https://travis-ci.org/astro/node-expat/branches) [](http://standardjs.com/) ## Motivation You use [Node.js](https://nodejs.org) for speed? You process XML streams? Then you want the fastest XML parser: [libexpat](http://expat.sourceforge.net/)! ## Install ``` npm install node-expat ``` ## Usage Important events emitted by a parser: ```javascript (function () { "use strict"; var expat = require('node-expat') var parser = new expat.Parser('UTF-8') parser.on('startElement', function (name, attrs) { console.log(name, attrs) }) parser.on('endElement', function (name) { console.log(name) }) parser.on('text', function (text) { console.log(text) }) parser.on('error', function (error) { console.error(error) }) parser.write('
Foobar
') }()) ``` ## API * `#on('startElement' function (name, attrs) {})` * `#on('endElement' function (name) {})` * `#on('text' function (text) {})` * `#on('processingInstruction', function (target, data) {})` * `#on('comment', function (s) {})` * `#on('xmlDecl', function (version, encoding, standalone) {})` * `#on('startCdata', function () {})` * `#on('endCdata', function () {})` * `#on('entityDecl', function (entityName, isParameterEntity, value, base, systemId, publicId, notationName) {})` * `#on('error', function (e) {})` * `#stop()` pauses * `#resume()` resumes ## Error handling We don't emit an error event because libexpat doesn't use a callback either. Instead, check that `parse()` returns `true`. A descriptive string can be obtained via `getError()` to provide user feedback. Alternatively, use the Parser like a node Stream. `write()` will emit error events. ## Namespace handling A word about special parsing of *xmlns:* this is not necessary in a bare SAX parser like this, given that the DOM replacement you are using (if any) is not relevant to the parser. ## Benchmark `npm run benchmark` | module | ops/sec | native | XML compliant | stream | |---------------------------------------------------------------------------------------|--------:|:------:|:-------------:|:--------------:| | [sax-js](https://github.com/isaacs/sax-js) | 99,412 | ☐ | ☑ | ☑ | | [node-xml](https://github.com/dylang/node-xml) | 130,631 | ☐ | ☑ | ☑ | | [libxmljs](https://github.com/polotek/libxmljs) | 276,136 | ☑ | ☑ | ☐ | | **node-expat** | 322,769 | ☑ | ☑ | ☑ | Higher is better. ## Testing ``` npm install -g standard npm test ``` ## Windows If you fail to install node-expat as a dependency of node-xmpp, please update node-xmpp as it doesn't use node-expat anymore. Dependencies for `node-gyp` https://github.com/TooTallNate/node-gyp#installation See https://github.com/astro/node-expat/issues/78 if you are getting errors about not finding `nan.h`. ### expat.vcproj ``` VCBUILD : error : project file 'node-expat\build\deps\libexpat\expat.vcproj' was not found or not a valid proj ect file. [C:\Users\admin\AppData\Roaming\npm\node_modules\node-expat\build\bin ding.sln] ``` Install [Visual Studio C++ 2012](http://go.microsoft.com/?linkid=9816758) and run npm with the [`--msvs_version=2012` flag](http://stackoverflow.com/a/16854333/937891). node-expat-2.3.18/benchmark.js 0000664 0000000 0000000 00000003221 13473600530 0016140 0 ustar 00root root 0000000 0000000 'use strict' var benchmark = require('benchmark') var nodeXml = require('node-xml') var libxml = null var expat = require('./') var sax = require('sax') var LtxSaxParser = require('ltx/lib/parsers/ltx') try { libxml = require('libxmljs') } catch (err) { console.error('Cannot load libxmljs, please install it manually:', err) } function NodeXmlParser () { var parser = new nodeXml.SaxParser(function (cb) {}) this.parse = function (s) { parser.parseString(s) } this.name = 'node-xml' } function LibXmlJsParser () { var parser = new libxml.SaxPushParser(function (cb) {}) this.parse = function (s) { parser.push(s, false) } this.name = 'libxmljs' } function SaxParser () { var parser = sax.parser() this.parse = function (s) { parser.write(s).close() } this.name = 'sax' } function ExpatParser () { var parser = new expat.Parser() this.parse = function (s) { parser.parse(s, false) } this.name = 'node-expat' } function LtxParser () { var parser = new LtxSaxParser() this.parse = function (s) { parser.write(s) } this.name = 'ltx' } var parsers = [ SaxParser, NodeXmlParser, ExpatParser, LtxParser ].map(function (Parser) { return new Parser() }) if (libxml) { parsers.push(new LibXmlJsParser()) } var suite = new benchmark.Suite('parse') parsers.forEach(function (parser) { parser.parse('