Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcollina/saxophonist
Extract elements from large XML files with node.js streams
https://github.com/mcollina/saxophonist
Last synced: 12 days ago
JSON representation
Extract elements from large XML files with node.js streams
- Host: GitHub
- URL: https://github.com/mcollina/saxophonist
- Owner: mcollina
- License: mit
- Created: 2016-01-25T11:00:08.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-02-12T12:43:22.000Z (almost 5 years ago)
- Last Synced: 2024-12-25T10:03:16.059Z (15 days ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 11
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# saxophonist
Extract elements from large XML files with node.js streams
## Usage
```js
'use strict'var fs = require('fs')
var p = require('path')
var saxophonist = require('./')
var count = 0console.time('parsing time')
fs.createReadStream(p.join(__dirname, 'wikipedia', '1.xml'))
.pipe(saxophonist('page'))
.on('data', function () {
count++
})
.on('end', function () {
console.timeEnd('parsing time')
console.log('read', count, 'pages')
})
```The data format is:
```js
{
path: ['a', 'path', 'to', 'page'], // the path in the XML document
children: null, // or an array with elements like this
attributes: {}, // object with all element attribute
text: null // or string, containing the element text
}
```## Acknowledgements
saxophonist is sponsored by [nearForm](http://nearform.com).
## License
MIT