# xml-parser

> the little xml parser that could

Latest version **1.2.1** (published 2015-06-05) · MIT license · 78.4K weekly downloads

## Install

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

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: no esm support.

Negative: abandoned; low maintenance score; declining downloads.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2015-06-05 |
| First published | 2014-02-14 |
| Weekly downloads | 78.4K |
| License | MIT |
| TypeScript types | separate (@types/xml-parser) |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 103 |
| Maintainers | tjholowaychuk, segment |
| Keywords | xml, sucks |

## Links

- npm: https://www.npmjs.com/package/xml-parser
- Repository: https://github.com/segmentio/xml-parser
- Issues: https://github.com/segmentio/xml-parser/issues
- npm.io page: https://npm.io/package/xml-parser

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) ^2.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
- [nopt-usage](https://npm.io/package/nopt-usage.md) — 56.7K weekly downloads

## Recent versions

- 1.2.1 (latest) — 2015-06-05
- 1.2.0 — 2014-10-21
- 1.1.0 — 2014-10-04
- 1.0.0 — 2014-08-25
- 0.1.0 — 2014-06-27
- 0.0.1 — 2014-02-14

## README

# xml-parser

  Simple non-compiant XML parser because we just need to parse some basic responses and libxml takes forever to compile :D you probably don't want to use this unless you also have similar needs.

## Installation

```
$ npm install xml-parser
```

## Example

 JavaScript:

```js
var fs = require('fs');
var parse = require('xml-parser');
var xml = fs.readFileSync('examples/developerforce.xml', 'utf8');
var inspect = require('util').inspect;

var obj = parse(xml);
console.log(inspect(obj, { colors: true, depth: Infinity }));
```

XML:

```xml
<?xml version="1.0" encoding="utf-8"?>
 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns="urn:enterprise.soap.sforce.com">
   <soapenv:Body>
      <createResponse>
         <result>
            <id>003D000000OY9omIAD</id>
            <success>true</success>
         </result>
         <result>
            <id>001D000000HTK3aIAH</id>
            <success>true</success>
         </result>
      </createResponse>
   </soapenv:Body>
 </soapenv:Envelope>
```

Yields:

```js
{ declaration: { attributes: { version: '1.0', encoding: 'utf-8' } },
  root:
   { name: 'soapenv:Envelope',
     attributes:
      { 'xmlns:soapenv': 'http://schemas.xmlsoap.org/soap/envelope/',
        xmlns: 'urn:enterprise.soap.sforce.com' },
     children:
      [ { name: 'soapenv:Body',
          attributes: {},
          children:
           [ { name: 'createResponse',
               attributes: {},
               children:
                [ { name: 'result',
                    attributes: {},
                    children:
                     [ { name: 'id',
                         attributes: {},
                         children: [],
                         content: '003D000000OY9omIAD' },
                       { name: 'success', attributes: {}, children: [], content: 'true' } ],
                    content: '' },
                  { name: 'result',
                    attributes: {},
                    children:
                     [ { name: 'id',
                         attributes: {},
                         children: [],
                         content: '001D000000HTK3aIAH' },
                       { name: 'success', attributes: {}, children: [], content: 'true' } ],
                    content: '' } ],
               content: '' } ],
          content: '' } ],
     content: '' } }
```

# License

  MIT

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