Gathering detailed insights and metrics for xml-stream-saxes
Gathering detailed insights and metrics for xml-stream-saxes
npm install xml-stream-saxes
Typescript
Module System
Node Version
NPM Version
72
Supply Chain
97.6
Quality
74.4
Maintenance
100
Vulnerability
98.9
License
JavaScript (100%)
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Total Downloads
785
Last Day
17
Last Week
17
Last Month
20
Last Year
196
MIT License
111 Commits
2 Forks
1 Branches
1 Contributors
Updated on Jun 09, 2021
Minified
Minified + Gzipped
Latest Version
0.4.9
Package Id
xml-stream-saxes@0.4.9
Unpacked Size
32.14 kB
Size
9.79 kB
File Count
15
NPM Version
6.14.6
Node Version
10.22.1
Cumulative downloads
Total Downloads
Last Day
0%
17
Compared to previous day
Last Week
0%
17
Compared to previous week
Last Month
-9.1%
20
Compared to previous month
Last Year
83.2%
196
Compared to previous year
3
1
XmlStream is a Node.js XML stream parser and editor, based on saxes (libexpat SAX-like parser binding).
Fork of xml-stream
project which is unmaintained
$ npm install xml-stream-saxes
When working with large XML files, it is probably a bad idea to use an XML to JavaScript object converter, or simply buffer the whole document in memory. Then again, a typical SAX parser might be too low-level for some tasks (and often a real pain).
This is why we've rolled our own stream parser that tries to address these shortcomings. It processes an XML stream chunk by chunk and fires events only for nodes of interest, matching them with CSS-like selectors.
Supported events:
data
on outgoing data chunk,end
when parsing has ended,startElement[: selector]
on opening tag for selector match,updateElement[: selector]
on finished node for selector match
with its contents buffered,endElement[: selector]
on closing tag for selector match,text[: selector]
on tag text for selector match.When adding listeners for startElement
, updateElement
, and text
the
callback can modify the provided node, before it is sent to the consumer.
Selector syntax is CSS-like and currently supports:
ancestor descendant
parent > child
Take a look at the examples for more information.
Each of the four node events has a callback with one argument. When parsing, this argument is set to the current matched node. Having a chunk of XML like this:
1<item id="123" type="common"> 2 <title>Item Title</title> 3 <description>Description of this item.</description> 4 (text) 5</item>
The structure of the item element node would be:
1{ 2 title: 'Item Title', 3 description: 'Description of this item.', 4 '$': { 5 'id': '123', 6 'type': 'common' 7 }, 8 '$name': 'item', 9 '$text': '(text)' 10}
Naturally, element text and child elements wouldn't be known until discovered in the stream, so the structure may differ across events. The complete structure as displayed should be available on updateElement. The $name is not available on endElement.
It is sometimes required to select elements that have many children with one and the same name. Like this XML:
1<item id="1"> 2 <subitem>one</subitem> 3 <subitem>two</subitem> 4</item> 5<item id="2"> 6 <subitem>three</subitem> 7 <subitem>four</subitem> 8 <subitem>five</subitem> 9</item>
By default, parsed element node contains children as properties. In the case of several children with same names, the last one would overwrite others. To collect all of subitem elements in an array use collect:
1xml.collect('subitem'); 2xml.on('endElement: item', function(item) { 3 console.log(item); 4})
By default, element text is returned as one concatenated string. In this XML:
1<item> 2 one <a>1</a> 3 two <b>2</b> 4</item>
The value of $text for item would be: one 1 two 2
without any
indication of the order of element a, element b, and text parts.
To preserve this order:
1xml.preserve('item'); 2xml.on('endElement: item', function(item) { 3 console.log(item); 4})
If you want parsing to pause (for example, until some asynchronous operation of yours is finished), you can pause and resume XML parsing:
1xml.pause(); 2myAsyncFunction( function() { 3 xml.resume(); 4});
Beware that resume() must not be called from within a handler callback.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Score
Last Scanned on 2025-03-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More