# xml-parse-from-string

> DOMParser.parseFromString for XML with IE8 fallback

Latest version **1.0.1** (published 2017-05-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install xml-parse-from-string
pnpm add xml-parse-from-string
yarn add xml-parse-from-string
bun add xml-parse-from-string
```

## 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.0.1 |
| Published | 2017-05-18 |
| First published | 2015-03-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | ie8, fallback, dom, parser, DOMParser, xml, string, parse, browser, browserify, webpack, activeXObject |

## Links

- npm: https://www.npmjs.com/package/xml-parse-from-string
- Repository: https://github.com/Jam3/xml-parse-from-string
- Issues: https://github.com/Jam3/xml-parse-from-string/issues
- npm.io page: https://npm.io/package/xml-parse-from-string

## 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.0.1 (latest) — 2017-05-18
- 1.0.0 — 2015-03-13

## README

# xml-parse-from-string

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

A light browser wrapper around `DOMParser.parseFromString` for XML, with fallback for IE8 and other browsers.

- attempts to use DOMParser with `"application/xml"`
- falls back to `ActiveXObject('Microsoft.XMLDOM')`
- then falls back to `createElement` / `innerHTML`  

```js
var parseXML = require('xml-parse-from-string')

var str = '<root><foobar id="blah"></foobar></root>'
var doc = parseXML(str)
var tag = doc.getElementsByTagName('foobar')[0]

console.log(tag.getAttribute('id')) // -> "blah"
```

Be wary of subtle differences between implementations, such as case-sensitivity in `attribute.nodeName`.

PRs for Node version welcome.

## Usage

[![NPM](https://nodei.co/npm/xml-parse-from-string.png)](https://www.npmjs.com/package/xml-parse-from-string)

#### `root = parse(str)`

Parses the string as XML and returns the `root` element as a DOM element, so you can do operations similar to `document.getElementById`, `document.getElementsByTagName`, and so forth.

## License

MIT, see [LICENSE.md](http://github.com/Jam3/xml-parse-from-string/blob/master/LICENSE.md) for details.

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