# xmlstream2

> Pipeable XML parser

Latest version **1.1.1** (published 2015-06-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install xmlstream2
pnpm add xmlstream2
yarn add xmlstream2
bun add xmlstream2
```

## 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.1 |
| Published | 2015-06-18 |
| First published | 2015-03-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.8 |
| Dependencies | 10 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Sérgio Ramos |
| Maintainers | ramitos, drudge |
| Keywords | xml, stream, pipe |

## Links

- npm: https://www.npmjs.com/package/xmlstream2
- Repository: https://github.com/ramitos/xmlstream2
- Issues: http://github.com/ramitos/xmlstream2/issues
- npm.io page: https://npm.io/package/xmlstream2

## Dependencies (10)

- [sax](https://npm.io/package/sax.md) ^0.6.1
- [clone](https://npm.io/package/clone.md) ^1.0.1
- [defaults](https://npm.io/package/defaults.md) ^1.0.0
- [inherits](https://npm.io/package/inherits.md) ^2.0.1
- [is-object](https://npm.io/package/is-object.md) ^1.0.1
- [is-string](https://npm.io/package/is-string.md) ^1.0.4
- [object-path-get](https://npm.io/package/object-path-get.md) 0.0.2
- [object-path-set](https://npm.io/package/object-path-set.md) 0.0.1
- [readable-stream](https://npm.io/package/readable-stream.md) ^1.0.33
- [stream-combiner2](https://npm.io/package/stream-combiner2.md) ^1.0.2

## 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.1 (latest) — 2015-06-18
- 1.1.0 — 2015-05-29
- 1.0.1 — 2015-03-12
- 1.0.0 — 2015-03-12

## README

# xmlstream2

Pipeable XML parser

Cousin of [jsonstream2](https://github.com/ramitos/jsonstream2) and inspired by [xml-stream](https://github.com/assistunion/xml-stream)


## install

```
npm install [--save/--save-dev] xmlstream2
```

## example

```xml
<?xml version="1.0"?>
<myscript>
  <sql>
    <query error="fast" conn="conn1" stmt="stmt1">
      <success></success>
    </query>
    <fetch block="all" desc="on" stmt="stmt1">
      <row>
        <data desc="id">74</data>
        <data desc="name">sramos</data>
      </row>
      <success>+++ success stmt1</success>
    </fetch>
    <free>
      <success>+++ success </success>
    </free>
  </sql>
</myscript>
```

```js
var XMLStream = require('xmlstream2');
var through = require('through2');
var writable = require('writable');
var fs = require('fs');


var rs = fs.createReadStream('./ex.xml');
rs.pipe(XMLStream('myscript.sql.fetch.row'))
.pipe(through.obj(function(row, enc, fn) {
  console.log(JSON.stringify(row, null, 2));
  fn();
}))
.pipe(writable({
  objectMode: true
}, function(chunk, enc, fn) {
  fn();
}));
```

```json
{
  "_attributes": {},
  "_isSelfClosing": false,
  "_name": "row",
  "data": [
    {
      "_value": "74",
      "_attributes": {
        "desc": "id"
      },
      "_isSelfClosing": false,
      "_name": "data"
    },
    {
      "_value": "sramos",
      "_attributes": {
        "desc": "name"
      },
      "_isSelfClosing": false,
      "_name": "data"
    }
  ]
}
```

## license

MIT

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