# saxo-parser

> A friendly way to configure a SAX parser

Latest version **1.1.0** (published 2022-04-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install saxo-parser
pnpm add saxo-parser
yarn add saxo-parser
bun add saxo-parser
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2022-04-12 |
| First published | 2016-03-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 14.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nicolas Chevolot |
| Maintainers | nch3v |
| Keywords | sax, xml |

## Links

- npm: https://www.npmjs.com/package/saxo-parser
- Repository: https://github.com/nch3v/saxo-parser
- Homepage: https://github.com/nch3v/saxo-parser#readme
- Issues: https://github.com/nch3v/saxo-parser/issues
- npm.io page: https://npm.io/package/saxo-parser

## Dependencies (1)

- [sax](https://npm.io/package/sax.md) ^1.2.4

## 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

- 1.1.0 (latest) — 2022-04-12
- 1.0.1 — 2016-03-25
- 1.0.0 — 2016-03-25

## README

SaxoParser
=========

## Purpose

SaxoParser is a helper to configure a sax parser using a self descriptive configuration object.

## Installation

`npm i -S saxo-parser`

## Usage

```
var SaxoParser = require('saxo-parser');

var saxo = new SaxoParser({
	myTag : {
		_open: function(tag) {
			tag.data = {};
			tag.data.someProp = tag.attributes.someProp;
			tag.data.moreProps = [];
		},
		_close: function(tag) {
			// do something with tag.data
			console.log(JSON.stringify(tag.data));
		},
		mySubTag : {
			_close: function(tag) {
				tag.parent.data.moreProps.push(tag.text);
			}
		}
	}
});

saxo.parseString('<root><myTag someProp="someValue"><mySubTag>Some</mySubTag><mySubTag>Text</mySubTag></myTag></root>');

```

## API

The constructor function takes an object describing what function should be called when parsing each xml element.

The entries of the object can be either a tag element name or a special function `_open`, `_text` (matches both text and cdata nodes) or `_close`. None of the special method is mandatory and should be used depending of the object to be parsed.

The parser can then parse a string with `parseString`, an inputStream with `parseStream` or a file with `parseFile`

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