Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NaturalIntelligence/fast-xml-parser
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.0.8
Choose a base ref
...
head repository: NaturalIntelligence/fast-xml-parser
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.0.9
Choose a head ref
  • 9 commits
  • 22 files changed
  • 5 contributors

Commits on Feb 25, 2025

  1. disable publish please from workflow

    amitguptagwl authored Feb 25, 2025
    Copy the full SHA
    00916e2 View commit details
  2. Update node.js.yml

    amitguptagwl authored Feb 25, 2025
    Copy the full SHA
    4311158 View commit details
  3. Update node.js.yml

    amitguptagwl authored Feb 25, 2025
    Copy the full SHA
    efd45cf View commit details

Commits on Feb 26, 2025

  1. fix: support numeric entities with values over 0xFFFF (#726)

    Numeric entities over U+FFFF would be truncated to their lower two bytes
    due to use of `String.fromCharCode` which only returns a UTF-16 single
    code unit. Replacing the relevant calls with `String.fromCodePoint`
    addresses the problem.
    mcdurdin authored Feb 26, 2025
    Copy the full SHA
    5b6000a View commit details
  2. update strnum to fix parsing 0 if skiplike option is used

    amitguptagwl committed Feb 26, 2025
    1
    Copy the full SHA
    56107fe View commit details

Commits on Mar 5, 2025

  1. fix: update benchmark so it's buildable (#731)

    - move files from .js to .mjs so they are usable as modules
    - shim __dirname using fileURLToPath
    - add a benchmark/README.md explaining the build process (such as it is)
    - update CONTRIBUTING.md to link to the new README.md
    - fix backslashes in CONTRIBUTING.md
    
    Fixes: #730
    srl295 authored Mar 5, 2025
    Copy the full SHA
    af4f1d2 View commit details

Commits on Mar 13, 2025

  1. ci: build with Node 18.x (#734)

    The version was missing in the range from 14 to 22.
    tbouffard authored Mar 13, 2025
    Copy the full SHA
    6ed9ea2 View commit details

Commits on Mar 14, 2025

  1. update release info

    amitguptagwl committed Mar 14, 2025
    Copy the full SHA
    7351cdf View commit details
  2. Update README

    amitguptagwl committed Mar 14, 2025
    Copy the full SHA
    1d39239 View commit details
8 changes: 4 additions & 4 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -15,17 +15,17 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16.x, 20.x, 22.x]
node-version: [14.x, 16.x, 18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install && npm remove publish-please
env:
PUBLISH_PLEASE_DISABLE_PROMPT: true
- name: Set PUBLISH_PLEASE_DISABLE_PROMPT
run: echo "PUBLISH_PLEASE_DISABLE_PROMPT=true" >> $GITHUB_ENV
- run: npm install --ignore-scripts
- run: npm run test
- uses: coverallsapp/github-action@v1.1.1
with:
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<small>Note: If you find missing information about particular minor version, that version must have been changed without any functional change in this library.</small>

**5.0.9 / 2025-03-14**
- fix: support numeric entities with values over 0xFFFF (#726) (By (Marc Durdin)[https://github.com/mcdurdin])
- fix: update strnum to fix parsing 0 if skiplike option is used

**5.0.8 / 2025-02-27**
- fix parsing 0 if skiplike option is used.
- updating strnum dependency

**5.0.7 / 2025-02-25**
- fix (#724) typings for cjs.

75 changes: 30 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
# [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)
[<img src="https://img.shields.io/badge/Try-me-blue.svg?colorA=FFA500&colorB=0000FF" alt="Try me"/>](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)

[![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.

<img align="right" src="static/img/fxp_logo.png" width="180px" alt="FXP logo"/>

* Validate XML data syntactically. Use [detailed-xml-validator](https://github.com/NaturalIntelligence/detailed-xml-validator/) to verify business rules.
* Parse XML to JS Objectand vice versa
* Common JS, ESM, and browser compatible
* Faster than any other pure JS implementation.

It can handle big files (tested up to 100mb). XML Entities, HTML entities, and DOCTYPE entites are supported. Unpaired tags (Eg `<br>` in HTML), stop nodes (Eg `<script>` in HTML) are supported. It can also preserve Order of tags in JS object

---
# Your Support, Our Motivation

<small>Checkout our new library [Text2Chart](https://solothought.com/text2chart/flow) that constructs flow chart out of simple text. Very helpful in creating or alayzing an algorithm, and documentation purpose</small>
<br>
## Try out our New Thoughts

We've recently launched **Flowgger**
<a href="https://github.com/solothought/flowgger"> <img src="static/img/flowgger_h.webp" alt="Flowgger Logging Framework" /></a>

Don't forget to check our new library [Text2Chart](https://solothought.com/text2chart/flow) that constructs flow chart out of simple text. Very helpful in creating or alayzing an algorithm, and documentation purpose.

## Financial Support

Sponsor this project

@@ -50,9 +63,9 @@ Through OpenCollective
-->

![fxp_sponsors](https://raw.githubusercontent.com/NaturalIntelligence/ThankYouBackers/main/assets/NI_sponsors.jpg)
- <a href="https://github.com/cocopon" target="_blank">Hiroki Kokubun</a>

> This is a donation. No goods or services are expected in return. Any requests for refunds for those purposes will be rejected.
## Users

<a href="https://github.com/renovatebot/renovate" title="renovate" ><img src="https://avatars1.githubusercontent.com/u/38656520" width="60px" ></a>
@@ -79,30 +92,7 @@ Through OpenCollective

---

## Main Features

<img align="right" src="static/img/fxp_logo.png" width="180px" alt="FXP logo"/>

* 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 `<br>` in HTML), stop nodes (Eg `<script>` 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.

## v6
I developed v6 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 v6, you have more control on parsing output. Check [docs](./docs/v6) for syntax help and basic understanding.

Please leave a comment in discussion forum for your suggestions and if you really need v6.
# More about this library

## How to use

@@ -153,7 +143,7 @@ Bundle size
| fxp.min.js | 26K |
| fxvalidator.min.js | 5.7K |

### Documents
## Documents
<table>
<tr><td>v3</td><td>v4 and v5</td><td>v6</td></tr>
<tr>
@@ -179,8 +169,9 @@ Bundle size
</tr>
</table>

**note**: version 6 is released with version 4 for experimental use. Based on it's demand, it'll be developed and the features can be different in final release.
Version 5 has the same functionalities as version 4.
**note**:
- Version 6 is released with version 4 for experimental use. Based on it's demand, it'll be developed and the features can be different in final release.
- Version 5 has the same functionalities as version 4.

## Performance
<small>negative means error</small>
@@ -198,10 +189,9 @@ Version 5 has the same functionalities as version 4.
<img src="./docs/imgs/XMLBuilder_v4.png" width="50%" />
* Y-axis: requests per second



<!-- [![](static/img/ni_ads_ads.gif)](https://github.com/NaturalIntelligence/ads/) -->

---

## Usage Trend

@@ -211,20 +201,15 @@ Version 5 has the same functionalities as version 4.
<img src="https://npm-compare.com/img/npm-trend/THREE_YEARS/fast-xml-parser.png" width="50%" alt="NPM Usage Trend of fast-xml-parser" />
</a>

## Supporters
### Contributors
# Supporters
#### Contributors

This project exists thanks to [all](graphs/contributors) the people who contribute. [[Contribute](docs/CONTRIBUTING.md)].
<!-- <a href="graphs/contributors"><img src="https://opencollective.com/fast-xml-parser/contributors.svg?width=890&button=false" /></a> -->
<!--
### Lead Maintainers
![Amit Gupta](https://avatars1.githubusercontent.com/u/7692328?s=100&v=4)
[![Vohmyanin Sergey Vasilevich](https://avatars3.githubusercontent.com/u/783335?s=100&v=4)](https://github.com/Delagen)

### All Contributors -->
<a href="graphs/contributors"><img src="https://opencollective.com/fast-xml-parser/contributors.svg?width=890&button=false" /></a>

### Backers

#### Backers from Open collective

Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/fast-xml-parser#backer)]

33 changes: 33 additions & 0 deletions benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# fast-xml-parser benchmarks

Part of [fast-xml-parser](../README.md)

## Building

```shell
$ npm i
```

## Testing

### All Benchmarks

```shell
$ npm t
```

### Parser Benchmars

```shell
$ npm run parser
```

### Builder Benchmarks

```shell
$ npm run builder
```

## License

See [../README.md](../README.md#license)
5 changes: 5 additions & 0 deletions benchmark/XmlBuilder.js → benchmark/XmlBuilder.mjs
Original file line number Diff line number Diff line change
@@ -6,6 +6,11 @@ const suite = new Benchmark.Suite("XML Builder benchmark");
import {XMLBuilder} from "../src/fxp.js";
import xml2js from "xml2js";
const xml2jsBuilder = new xml2js.Builder();
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';

// compatibility
const __dirname = dirname(fileURLToPath(import.meta.url));

import fs from "fs";
import path from "path";
5 changes: 5 additions & 0 deletions benchmark/XmlParser.js → benchmark/XmlParser.mjs
Original file line number Diff line number Diff line change
@@ -5,6 +5,11 @@ import {XMLParser} from "../src/fxp.js";
import xml2js from "xml2js";
import fxpv3 from "fast-xml-parser";
import { convert } from 'xmlbuilder2';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';

// compatibility
const __dirname = dirname(fileURLToPath(import.meta.url));

const suite = new Benchmark.Suite("XML Parser benchmark");

4 changes: 3 additions & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,9 @@
"private": true,
"description": "Performance test",
"scripts": {
"perf": "node perfTest3.js"
"parser": "node XmlParser.mjs",
"builder": "node XmlBuilder.mjs",
"test": "npm run parser && npm run builder && node try.mjs"
},
"devDependencies": {
"benchmark": "^2.1.4",
7 changes: 6 additions & 1 deletion benchmark/try.js → benchmark/try.mjs
Original file line number Diff line number Diff line change
@@ -2,6 +2,11 @@ import fs from "fs";
import path from "path";
// const fileNamePath = path.join(__dirname, "../spec/assets/test.json");//1.5k
// const jsonData = JSON.parse(fs.readFileSync(fileNamePath).toString());
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';

// compatibility
const __dirname = dirname(fileURLToPath(import.meta.url));


// const xml2js = require("xml2js");
@@ -16,4 +21,4 @@ const xmlData = fs.readFileSync(fileNamePath).toString();
const fxpParserForOrderedJs = new XMLParser({preserveOrder: true});
console.log(
JSON.stringify(fxpParserForOrderedJs.parse(xmlData), null, 4)
);
);
3 changes: 2 additions & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@ Here is the check list to publish any change
* Changes are well discussed by raising github issue. So they are well known by other contributors and users
* Echoing the above point. The purpose / goal for the PR should be mentioned in the description.
* Multiple unrelated changes should not be clubbed in single PR.
* Please run perf tests `$ node benchmark\XmlParser.js` or `$ node benchmark\XmlBuilder.js` before and after the changes. And mention it in PR description.
* Please run perf tests `$ node benchmark/XmlParser.mjs` or `$ node benchmark/XmlBuilder.mjs` before and after the changes. And mention it in PR description.
* See [benchmark/README.md](../benchmark/README.md) for details
* If you are adding any dependency (specially if it is not the dev dependency) please check that
* it is not dependent on other language packages like c/c++
* the package is not very old, very new, discontinued, or has any vulnerability etc.
Loading