# xmlrun

> Convert xml to a tree of objects with a run function to traverse all of them

Latest version **0.0.22** (published 2020-09-28) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.22 |
| Published | 2020-09-28 |
| First published | 2020-09-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 (+8 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | fillano.feng@gmail.com |
| Maintainers | fillano |

## Links

- npm: https://www.npmjs.com/package/xmlrun
- Repository: https://github.com/fillano/xmlrun
- Homepage: https://github.com/fillano/xmlrun#readme
- Issues: https://github.com/fillano/xmlrun/issues
- npm.io page: https://npm.io/package/xmlrun

## Dependencies (1)

- [xmldom](https://npm.io/package/xmldom.md) ^0.3.0

## Recent versions

- 0.0.22 (latest) — 2020-09-28
- 0.0.1 — 2020-09-28

## README

# xmlrun
Convert xml to a tree of objects with a run function to traverse all of them

# usage

## in node.js

```
let xmlrun = require('xmlrun');
let runner = xmlrun('xml text');
runner.setRunner('default', function(target) {
    let result = {
        type: xmlrun.utils.getNodeTypeDesc(target.type),
        tagName: target.tag,
        attributes: target.attr,
        value: target.val,
        children: []
    }
    if(!!target.child) {
        result.children = target.child.reduce((acc, cur) => {
            acc.push(cur.run());
            return acc;
        }, []);
    }
    return result;
});
let result = runner.run();
console.log(JSON.stringify(result, null, 2));
```

# description

xmlrun use DOMParser provided by xmldom or browser env to build a node tree with a run method for each node. run the method with proper runner then the method will tranverse all node recursively. currently, it should be done by runner manually.

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