rpbouman / xmlazy

Library for lazy DOM and XML parsing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🦥 xmlazy

A library for streaming xml and lazy dom

Features

  • xml streaming (sax reader)
  • lazy document building (DOM)

How to use: Node

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();

How to use: Browser

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>

Developer environment requirements

To run this project, you will need:

Running tests

npm run test

Running Samples

npm run serve

Then navigate to: http://127.0.0.1:8080/samples/browser/index.html

Acknowledgements

Project setup: rollup-jest-boilerplate

About

Library for lazy DOM and XML parsing.

License:MIT License


Languages

Language:JavaScript 100.0%