# node-xml-lite

> Pure javascript XML ANSI/Unicode SAX parser for Node.js

Latest version **0.0.7** (published 2016-03-24) · 0 weekly downloads

## Install

```sh
npm install node-xml-lite
pnpm add node-xml-lite
yarn add node-xml-lite
bun add node-xml-lite
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2016-03-24 |
| First published | 2012-07-08 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 19 |
| Author | Henri Gourvest |
| Maintainers | hgourvest |
| Keywords | xml, sax, ansi |

## Links

- npm: https://www.npmjs.com/package/node-xml-lite
- Repository: https://github.com/hgourvest/node-xml-lite
- Homepage: http://github.com/hgourvest/node-xml-lite
- Issues: https://github.com/hgourvest/node-xml-lite/issues
- npm.io page: https://npm.io/package/node-xml-lite

## Dependencies (1)

- [iconv-lite](https://npm.io/package/iconv-lite.md) >=0.2.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.0.7 (latest) — 2016-03-24
- 0.0.6 — 2015-09-14
- 0.0.5 — 2015-08-08
- 0.0.4 — 2015-07-27
- 0.0.3 — 2013-11-25
- 0.0.2 — 2012-08-10
- 0.0.1 — 2012-07-08

## README

# node-xml-lite

 - This is a pure javascript XML SAX parser for Node.js.
 - The specificity of this xml parser is that it can parse a document from a Buffer.
 - It relies on iconv-lite to decode the text according to the code page of the document.

## Install

    npm install node-xml-lite

## Simple usage
    
### Parse a file 
 
    xml = require("node-xml-lite");
    
    xml.parseFile(filename, function(err, root){
      ...
    });
    
### Parse a file synchronously

    xml.parseFileSync(filename));
    
### Parse a string

    xml.parseString("<xml>hello</xml>");

### Parse a buffer

    xml.parseBuffer(new Buffer("<xml>hello</xml>"));

## Advanced usage

### parsing a file in SAX mode

    xml.SAXParseFile(filename,
      function(state, a, b) {
        switch (state) {
          case xml.xtOpen:
            // a is node name
            ...
            break;
          case xml.xtClose
            ...
            break;
          case xml.xtAttribute:
            // a is attribute name
            // b is attribute value
            ...
            break;
          case xml.xtText:
            // a is a text value
            break;
          case xml.xtCData:
            // a is a CDATA text value
            ...
            break;
          case xml.xtComment
            // a is a comment text value
            ...
            break;
        };
        // tell the parser to continue
        return true;
      },
      function(err){
        // parser done, check error
        ...
      }
    );
    
you can also use the sync function, 

    xml.SAXParseFileSync(filename, event)
    
### providing your own data to SAX parser

    var parser = new xml.XMLParser();
    var ret = parser.parserBuffer(buffer, len, event);
    if (ret === true) {
      // stopped by event result
    } else
    if (ret === false) {
      // there is a parsing error at:
      //   parser.line 
      //   parser.col
    } else
    if (ret === undefined) {
      // it is ok, continue ...
    }

you can also parse a string

    var ret = parser.parseString(str, event);

---
_Source: https://npm.io/package/node-xml-lite · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
