A library for streaming xml and lazy dom
- xml streaming (sax reader)
- lazy document building (DOM)
Using the reader:
import * as xmlazy from 'xmlazy';
const reader = new xmlazy.SaxStringReader('<hello>world!</hello>');
let readerResult, lazyDomNode;
while (!(readerResult = reader.next()).done){
lazyDomNode = readerResult.value;
switch (lazyDomNode.nodeType) {
// do something interesting
}
}
Building a DOM document:
import * as xmlazy from 'xmlazy';
const reader = new xmlazy.SaxStringReader('<hello>world!</hello>');
const domDocument = reader.buildDocument();
Using the reader:
<script type="module">
import * as xmlazy from '/dist/xmlazy.bundle.js';
const reader = new xmlazy.SaxStringReader('<hello>world!</hello>');
let readerResult, lazyDomNode;
while (!(readerResult = reader.next()).done){
lazyDomNode = readerResult.value;
switch (lazyDomNode.nodeType) {
// do something interesting
}
}
</script>
Building a DOM document:
<script type="module">
import * as xmlazy from '/dist/xmlazy.bundle.js';
const reader = new xmlazy.SaxStringReader('<hello>world!</hello>');
const domDocument = reader.buildDocument();
</script>
To run this project, you will need:
- Node.js >= v10.5.0, use nvm - install instructions
- Yarn >= v1.7.0 - install instructions ("Alternatives" tab)
npm run test
npm run serve
Then navigate to: http://127.0.0.1:8080/samples/browser/index.html
Project setup: rollup-jest-boilerplate