@rgrove/parse-xml 4.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -25
- package/dist/browser.js +642 -223
- package/dist/browser.js.map +4 -4
- package/dist/global.min.js +9 -8
- package/dist/global.min.js.map +4 -4
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/Parser.d.ts +49 -6
- package/dist/lib/Parser.d.ts.map +1 -1
- package/dist/lib/Parser.js +133 -102
- package/dist/lib/Parser.js.map +1 -1
- package/dist/lib/StringScanner.d.ts +5 -5
- package/dist/lib/StringScanner.d.ts.map +1 -1
- package/dist/lib/StringScanner.js +9 -9
- package/dist/lib/StringScanner.js.map +1 -1
- package/dist/lib/XmlDeclaration.d.ts +30 -0
- package/dist/lib/XmlDeclaration.d.ts.map +1 -0
- package/dist/lib/XmlDeclaration.js +36 -0
- package/dist/lib/XmlDeclaration.js.map +1 -0
- package/dist/lib/XmlDocument.d.ts +4 -2
- package/dist/lib/XmlDocument.d.ts.map +1 -1
- package/dist/lib/XmlDocument.js.map +1 -1
- package/dist/lib/XmlDocumentType.d.ts +37 -0
- package/dist/lib/XmlDocumentType.d.ts.map +1 -0
- package/dist/lib/XmlDocumentType.js +39 -0
- package/dist/lib/XmlDocumentType.js.map +1 -0
- package/dist/lib/XmlError.d.ts +24 -0
- package/dist/lib/XmlError.d.ts.map +1 -0
- package/dist/lib/XmlError.js +52 -0
- package/dist/lib/XmlError.js.map +1 -0
- package/dist/lib/XmlNode.d.ts +20 -1
- package/dist/lib/XmlNode.d.ts.map +1 -1
- package/dist/lib/XmlNode.js +28 -3
- package/dist/lib/XmlNode.js.map +1 -1
- package/dist/lib/syntax.d.ts.map +1 -1
- package/dist/lib/syntax.js +1 -1
- package/dist/lib/syntax.js.map +1 -1
- package/dist/lib/types.d.ts +2 -2
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +20 -18
- package/src/index.ts +3 -0
- package/src/lib/Parser.ts +195 -118
- package/src/lib/StringScanner.ts +10 -10
- package/src/lib/XmlDeclaration.ts +58 -0
- package/src/lib/XmlDocument.ts +4 -2
- package/src/lib/XmlDocumentType.ts +67 -0
- package/src/lib/XmlError.ts +80 -0
- package/src/lib/XmlNode.ts +33 -3
- package/src/lib/syntax.ts +1 -1
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ Or, if you like living dangerously, you can load [the minified bundle](https://u
|
|
|
38
38
|
|
|
39
39
|
## Not Features
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
While this parser is capable of parsing document type declarations (`<!DOCTYPE ... >`) and including them in the node tree, it doesn't actually do anything with them. External document type definitions won't be loaded, and the parser won't validate the document against a DTD or resolve custom entity references defined in a DTD.
|
|
42
42
|
|
|
43
43
|
In addition, the only supported character encoding is UTF-8 because it's not feasible (or useful) to support other character encodings in JavaScript.
|
|
44
44
|
|
|
@@ -149,64 +149,79 @@ Also, it was fun.
|
|
|
149
149
|
|
|
150
150
|
## Benchmark
|
|
151
151
|
|
|
152
|
-
Here's how parse-xml stacks up against
|
|
152
|
+
Here's how parse-xml's performance stacks up against a few comparable libraries:
|
|
153
|
+
|
|
154
|
+
- [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser), which claims to be the fastest pure JavaScript XML parser
|
|
155
|
+
- [libxmljs2](https://github.com/marudor/libxmljs2), which is based on the native libxml library written in C
|
|
156
|
+
- [xmldoc](https://github.com/nfarina/xmldoc), which is based on [sax-js](https://github.com/isaacs/sax-js)
|
|
153
157
|
|
|
154
158
|
While libxmljs2 is faster at parsing medium and large documents, its performance comes at the expense of a large C dependency, no browser support, and a [history of security vulnerabilities](https://www.cvedetails.com/vulnerability-list/vendor_id-1962/product_id-3311/Xmlsoft-Libxml2.html) in the underlying libxml2 library.
|
|
155
159
|
|
|
160
|
+
In these results, "ops/s" refers to operations per second. Higher is faster.
|
|
161
|
+
|
|
156
162
|
```
|
|
157
|
-
Node.js v18.
|
|
163
|
+
Node.js v18.14.0 / Darwin arm64
|
|
158
164
|
Apple M1 Max
|
|
159
165
|
|
|
160
166
|
Running "Small document (291 bytes)" suite...
|
|
161
167
|
Progress: 100%
|
|
162
168
|
|
|
163
|
-
@rgrove/parse-xml 4.
|
|
164
|
-
|
|
169
|
+
@rgrove/parse-xml 4.1.0:
|
|
170
|
+
191 553 ops/s, ±0.10% | fastest
|
|
171
|
+
|
|
172
|
+
fast-xml-parser 4.1.1:
|
|
173
|
+
142 565 ops/s, ±0.11% | 25.57% slower
|
|
165
174
|
|
|
166
|
-
libxmljs2 0.
|
|
167
|
-
74
|
|
175
|
+
libxmljs2 0.31.0 (native):
|
|
176
|
+
74 646 ops/s, ±0.30% | 61.03% slower
|
|
168
177
|
|
|
169
178
|
xmldoc 1.2.0 (sax-js):
|
|
170
|
-
|
|
179
|
+
66 823 ops/s, ±0.09% | slowest, 65.12% slower
|
|
171
180
|
|
|
172
|
-
Finished
|
|
173
|
-
Fastest: @rgrove/parse-xml 4.
|
|
181
|
+
Finished 4 cases!
|
|
182
|
+
Fastest: @rgrove/parse-xml 4.1.0
|
|
174
183
|
Slowest: xmldoc 1.2.0 (sax-js)
|
|
175
184
|
|
|
176
185
|
Running "Medium document (72081 bytes)" suite...
|
|
177
186
|
Progress: 100%
|
|
178
187
|
|
|
179
|
-
@rgrove/parse-xml 4.
|
|
180
|
-
1
|
|
188
|
+
@rgrove/parse-xml 4.1.0:
|
|
189
|
+
1 065 ops/s, ±0.11% | 49.81% slower
|
|
181
190
|
|
|
182
|
-
|
|
183
|
-
|
|
191
|
+
fast-xml-parser 4.1.1:
|
|
192
|
+
637 ops/s, ±0.12% | 69.98% slower
|
|
193
|
+
|
|
194
|
+
libxmljs2 0.31.0 (native):
|
|
195
|
+
2 122 ops/s, ±2.48% | fastest
|
|
184
196
|
|
|
185
197
|
xmldoc 1.2.0 (sax-js):
|
|
186
|
-
|
|
198
|
+
444 ops/s, ±0.36% | slowest, 79.08% slower
|
|
187
199
|
|
|
188
|
-
Finished
|
|
189
|
-
Fastest: libxmljs2 0.
|
|
200
|
+
Finished 4 cases!
|
|
201
|
+
Fastest: libxmljs2 0.31.0 (native)
|
|
190
202
|
Slowest: xmldoc 1.2.0 (sax-js)
|
|
191
203
|
|
|
192
204
|
Running "Large document (1162464 bytes)" suite...
|
|
193
205
|
Progress: 100%
|
|
194
206
|
|
|
195
|
-
@rgrove/parse-xml 4.
|
|
196
|
-
|
|
207
|
+
@rgrove/parse-xml 4.1.0:
|
|
208
|
+
93 ops/s, ±0.10% | 53.27% slower
|
|
209
|
+
|
|
210
|
+
fast-xml-parser 4.1.1:
|
|
211
|
+
48 ops/s, ±0.60% | 75.88% slower
|
|
197
212
|
|
|
198
|
-
libxmljs2 0.
|
|
199
|
-
|
|
213
|
+
libxmljs2 0.31.0 (native):
|
|
214
|
+
199 ops/s, ±1.47% | fastest
|
|
200
215
|
|
|
201
216
|
xmldoc 1.2.0 (sax-js):
|
|
202
|
-
|
|
217
|
+
38 ops/s, ±0.09% | slowest, 80.9% slower
|
|
203
218
|
|
|
204
|
-
Finished
|
|
205
|
-
Fastest: libxmljs2 0.
|
|
219
|
+
Finished 4 cases!
|
|
220
|
+
Fastest: libxmljs2 0.31.0 (native)
|
|
206
221
|
Slowest: xmldoc 1.2.0 (sax-js)
|
|
207
222
|
```
|
|
208
223
|
|
|
209
|
-
See the [parse-xml-benchmark](https://github.com/rgrove/parse-xml-benchmark) repo for instructions on
|
|
224
|
+
See the [parse-xml-benchmark](https://github.com/rgrove/parse-xml-benchmark) repo for instructions on how to run this benchmark yourself.
|
|
210
225
|
|
|
211
226
|
## License
|
|
212
227
|
|