Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/NaturalIntelligence/fast-xml-parser
Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.
https://github.com/NaturalIntelligence/fast-xml-parser
cli command-line fast fast-xml-parser js js2xml json json2xml locale parser rapid validate validator xml xml2js xml2json xml2nimn
Last synced: about 2 months ago
JSON representation
Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.
- Host: GitHub
- URL: https://github.com/NaturalIntelligence/fast-xml-parser
- Owner: NaturalIntelligence
- License: mit
- Created: 2017-01-28T23:25:42.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-04-05T03:24:54.000Z (8 months ago)
- Last Synced: 2024-05-01T11:46:37.125Z (8 months ago)
- Topics: cli, command-line, fast, fast-xml-parser, js, js2xml, json, json2xml, locale, parser, rapid, validate, validator, xml, xml2js, xml2json, xml2nimn
- Language: JavaScript
- Homepage: https://naturalintelligence.github.io/fast-xml-parser/
- Size: 6.37 MB
- Stars: 2,364
- Watchers: 30
- Forks: 295
- Open Issues: 62
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: docs/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: .github/SECURITY.md
Awesome Lists containing this project
- awesome - fast-xml-parser - Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback. (Npm)
- awesome-nodejs-cn - fast-xml-parser - 验证和解析 XML (包 / 解析)
- awesome-nodejs - fast-xml-parser - Validate and parse XML. ![](https://img.shields.io/github/stars/NaturalIntelligence/fast-xml-parser.svg?style=social&label=Star) (Repository / Parsing)
- awesome-starred-test - NaturalIntelligence/fast-xml-parser - Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback. (JavaScript)
- awesome - fast-xml-parser
- awesome-nodejs - fast-xml-parser - Validate and parse XML. (Packages / Parsing)
- awesome-nodejs - fast-xml-parser - Validate XML, Parse XML to JS/JSON and vise versa, or parse XML to Nimn rapidly without C/C++ based libraries and no callback - ★ 295 (Parsing)
- awesome-node - fast-xml-parser - Validate and parse XML. (Packages / Parsing)
- awesome-nodejs-cn - fast-xml-parser - 验证&解析 XML. (目录 / 解析工具)
- awesome-nodejs-cn - fast-xml-parser - **star:2571** 验证和解析XML ![star > 2000][Awesome] (包 / 解析)
README
# [fast-xml-parser](https://www.npmjs.com/package/fast-xml-parser)
[![NPM quality][quality-image]][quality-url]
[![Coverage Status](https://coveralls.io/repos/github/NaturalIntelligence/fast-xml-parser/badge.svg?branch=master)](https://coveralls.io/github/NaturalIntelligence/fast-xml-parser?branch=master)
[](https://naturalintelligence.github.io/fast-xml-parser/)
[![NPM total downloads](https://img.shields.io/npm/dt/fast-xml-parser.svg)](https://npm.im/fast-xml-parser)Validate XML, Parse XML to JS Object, or Build XML from JS Object without C/C++ based libraries and no callback.
---
I had recently published a book, The Power Glasses. Please have a look. Your feedback would be helpful. You can [mail]([email protected]) me for a free copy.Sponsor this project
![fxp_sponsors](https://raw.githubusercontent.com/NaturalIntelligence/ThankYouBackers/main/assets/NI_sponsors.jpg)
## Users
The list of users are mostly published by Github or communicated directly. Feel free to contact if you find any information wrong.
---
## Main Features
* Validate XML data syntactically
* Parse XML to JS Object
* Build XML from JS Object
* Compatible to node js packages, in browser, and in CLI (click try me button above for demo)
* Faster than any other pure JS implementation.
* It can handle big files (tested up to 100mb).
* Controlled parsing using various options
* XML Entities, HTML entities, and DOCTYPE entites are supported.
* unpaired tags (Eg `
` in HTML), stop nodes (Eg `` in HTML) are supported.
* You can restore almost same XML from JSON
* Supports comments
* It can preserve Order of tags in JS object
* You can control if a single tag should be parsed into array.
* Supports parsing of PI (Processing Instruction) tags with XML declaration tags
* And many more other features.## v5
I developed v5 in Apr 2023. And I didn't get the chance to complete all the features. I've ensured that new features don't impact performance. With v5, you have more control on parsing output. Check [docs](./docs/v5) for syntax help and basic understanding.Please leave a comment in discussion forum for your suggestions and if you really need v5.
## How to use
To use as package dependency
`$ npm install fast-xml-parser`
or
`$ yarn add fast-xml-parser`To use as system command
`$ npm install fast-xml-parser -g`To use it on a **webpage** include it from a [CDN](https://cdnjs.com/libraries/fast-xml-parser)
**Example**
As CLI command
```bash
$ fxparser some.xml
```In a node js project
```js
const { XMLParser, XMLBuilder, XMLValidator} = require("fast-xml-parser");const parser = new XMLParser();
let jObj = parser.parse(XMLdata);const builder = new XMLBuilder();
const xmlContent = builder.build(jObj);
```In a HTML page
```html
<script src="path/to/fxp.min.js">
:const parser = new fxparser.XMLParser();
parser.parse(xmlContent);```
Bundle size
| Bundle Name | Size |
| ------------------ | ---- |
| fxbuilder.min.js | 6.5K |
| fxparser.min.js | 20K |
| fxp.min.js | 26K |
| fxvalidator.min.js | 5.7K |### Documents
v3v4v5
documents
- Getting Started
- XML Parser
- XML Builder
- XML Validator
- Entities
- HTML Document Parsing
- PI Tag processing
**note**: version 5 is released with version 4 tfor experimental use. Based on it's demand, it'll be developed and the features can be different in final release.
## Performance
negative means error### XML Parser
* Y-axis: requests per second
* X-axis: File size### XML Builder
* Y-axis: requests per second## Usage Trend
[Usage Trend of fast-xml-parser](https://npm-compare.com/fast-xml-parser#timeRange=THREE_YEARS)
## Supporters
### ContributorsThis project exists thanks to [all](graphs/contributors) the people who contribute. [[Contribute](docs/CONTRIBUTING.md)].
### Backers
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/fast-xml-parser#backer)]
# License
* MIT License![Donate $5](static/img/donation_quote.png)