# react-xml-parser

> XML parser for react-native

Latest version **1.1.8** (published 2020-10-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-xml-parser
pnpm add react-xml-parser
yarn add react-xml-parser
bun add react-xml-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.8 |
| Published | 2020-10-15 |
| First published | 2016-09-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 45 |
| Author | Matan Shiloah |
| Maintainers | matansh |
| Keywords | XML, react |

## Links

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

## 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.8 (latest) — 2020-10-15
- 1.1.9 (issue 35 and 33) — 2020-10-15
- 1.0.8001 (webpack) — 2018-12-22
- 1.1.7 — 2020-10-15
- 1.1.6 — 2020-02-14
- 1.1.5 — 2020-02-14
- 1.1.4 — 2020-02-14
- 1.1.3 — 2019-07-31
- 1.1.2 — 2019-02-02
- 1.1.1 — 2019-02-02
- 1.1.0 — 2019-02-02
- 1.0.9 — 2019-02-02
- 1.0.8 — 2018-09-10
- 1.0.7 — 2018-06-06
- 1.0.5 — 2018-03-16
- … 5 more at https://npm.io/package/react-xml-parser/versions

## README

# react-xml-parser

A simple and user-friendly XML parser for React-native developers.
This library's goal is to parse simple XML responses, from and to string.

# Installation

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

# Example

XML:

```
<?xml version='1.0' encoding='utf-8'?>
<Library>
   <Books count='1'>
       <Book id='1'>
           <Name>Me Before You</Name>
           <Author>Jojo Moyes</Author>
       </Book>
   </Books>
   <Music count=1>
       <CD id='2'>
           <Name>Houses of the Holy</Name>
           <Artist>Led Zeppelin</Artist>
       </CD>
   </Music>
</Library>
```

JS:

```
var XMLParser = require('react-xml-parser');
var xml = new XMLParser().parseFromString(xmlText);    // Assume xmlText contains the example XML
console.log(xml);
console.log(xml.getElementsByTagName('Name'));
```

Output:

```
// XML parsing response
{
    name: 'Library', attributes: {}, value: '', children: [
        {
            name: 'Books', attributes: { count: '1' }, value: '', children: [
                {
                    name: 'Book', attributes: { id: '1' }, value: '', children: [
                        {
                            name: 'Name', attributes: {}, value: 'Me Before You', children: []
                        }, {
                            name: 'Author', attributes: {}, value: 'Jojo Moyes', children: []
                        }
                    ]
                }
            ]
        },
        {
            name: 'Music', attributes: { count: '1' }, value: '', children: [
                {
                    name: 'CD', attributes: { id: '2' }, value: '', children: [
                        {
                            name: 'Name', attributes: {}, value: 'Houses of the Holy', children: []
                        }, {
                            name: 'Artist', attributes: {}, value: 'Led Zeppelin', children: []
                        }
                    ]
                }
            ]
        }
    ]
}

// getElementsByTagName response
[
    {
        name: 'Name', attributes: {}, value: 'Me Before You', children: []
    }, {
        name: 'Name', attributes: {}, value: 'Houses of the Holy', children: []
    }
]
```

# Usage

Methods that are currently supported:

1. parseFromString(string): Returns an XML object as described in the example output that represents the input text.

2. toString(XML object): Returns text representation of an input XML.

3. getElementsByTagName(string): Returns all tags with the same name as the method's input string (case-insensitive). for all possible tags, use '*' as input.

# License

ISC

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