
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
xml-splitter
Advanced tools
Provide an easy way to split or extract some nodes of very big XML files
It's native and full Javascript class, that provides an easy way to split huge XML data with one or more paths.
With npm do:
$ npm install xml-splitter
var XMLSplitter = require('xml-splitter')
xs = new XMLSplitter('/root/item')
xs.on('data', function(data) {
console.log(data)
})
xs.on('end', function(counter) {
console.log(counter+' slices !')
})
xs.parseString('<root><item><id>1</id></item><item><id>2</id></item></root>')
Output:
{ id: { '$t': '1' } }
{ id: { '$t': '2' } }
2 slices !
var XMLSplitter = require('xml-splitter')
xs = new XMLSplitter(['/root/item', '/root/entry'])
xs.on('data', function(data) {
console.log(data)
})
xs.on('end', function(counter) {
console.log(counter+' slices !')
})
xs.parseString('<root><item><id>1</id></item><entry><id>2</id></entry></root>')
Output:
{ id: { '$t': '1' } }
{ id: { '$t': '2' } }
2 slices !
var XMLSplitter = require('xml-splitter')
xs = new XMLSplitter('/root/item')
xs.on('data', function(data) {
console.log(data)
})
xs.on('end', function(counter) {
console.log(counter+' slices !')
})
xs.parseStream(process.stdin) // or process.stdin.pipe(xs.stream)
Use nodeunit to run the tests.
$ npm install nodeunit
$ nodeunit test
Create an new splitter, cutter is a string or an array of strings that contains path. Options are :
Split XML within a string
Split XML within a stream
Emits three elements on each slice: the data node (object), the node's tag name (string), and the node's path (string). For example:
var xs = new XMLSplitter('//(item|unit)')
xs.on('data', function (node, tag, path) {
console.log(node);
console.log(tag);
console.log(path);
})
xs.parseString('<record><item><value>X</value></item><unit><value>Y</value></unit></record>')
Output:
{ value: { '$t': 'X' } }
item
/record/item
{ value: { '$t': 'Y' } }
unit
/record/unit
Emit if the stream emit the close event OR if the stream is destroyed
Emit on the end of the XML parsing
Emit when something bad happened
The XPath standard is not supported, only basic paths (included namespaces) and fews operotors is implemented :
I do not think I will implement more operators.
FAQs
Provide an easy way to split or extract some nodes of very big XML files
The npm package xml-splitter receives a total of 2,816 weekly downloads. As such, xml-splitter popularity was classified as popular.
We found that xml-splitter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.