• Stars
    star
    2,318
  • Rank 19,858 (Top 0.4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.

fast-xml-parser

Backers on Open Collective Sponsors on Open Collective Known Vulnerabilities NPM quality Coverage Status Try me NPM total downloads

Validate XML, Parse XML to JS Object, or Build XML from JS Object without C/C++ based libraries and no callback.

Looking for maintainers

Support this project by becoming a Sponsor.

Click on Sponsor button above or Stubmatic donate button

Sponsors

Check ThankYouBackers for our supporters

Users

Check the list of all known users here;

The list of users is collected either from the list published by Github, cummunicated directly through mails/chat , or from other resources. If you feel that your name in the above list is incorrectly published or you're not the user of this library anymore then you can inform us to remove it. We'll do the necessary changes ASAP.

Main Features

FXP logo

  • Validate XML data syntactically
  • Parse XML to JS Object
  • Build XML from JS Object
  • Works with node packages, in browser, and in CLI (press 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.

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

Example

As CLI command

$ fxparser some.xml

In a node js project

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

<script src="path/to/fxp.min.js"></script>
:
<script>
  const parser = new fxparser.XMLParser();
  parser.parse(xmlContent);
</script>

Check lib folder for different browser bundles

Bundle Name Size
fxbuilder.min.js 5.2K
fxparser.js 50K
fxparser.min.js 17K
fxp.min.js 22K
fxvalidator.min.js 5.7K

Documents

v3

v4

  1. GettingStarted.md
  2. XML Parser
  3. XML Builder
  4. XML Validator
  5. Entities
  6. HTML Document Parsing
  7. PI Tag processing

Performance

XML Parser

  • Y-axis: requests per second
  • X-axis: File size

Large files

  • Y-axis: requests per second
  • X-axis: File size

XML Builder

  • Y-axis: requests per second

negative means error

Our other projects and research you must try

  • BigBit standard :
    • Single text encoding to replace UTF-8, UTF-16, UTF-32 and more with less memory.
    • Single Numeric datatype alternative of integer, float, double, long, decimal and more without precision loss.
  • Cytorus: Be specific and flexible while running E2E tests.
    • Run tests only for a particular User Story
    • Run tests for a route or from a route
    • Customizable reporting
    • Central dashboard for better monitoring
    • Options to integrate E2E tests with Jira, Github etc using Central dashboard Tian.
  • Stubmatic : Create fake webservices, DynamoDB or S3 servers, Manage fake/mock stub data, Or fake any HTTP(s) call.

Supporters

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! 🙏 [Become a backer]

License

  • MIT License

Donate $5

More Repositories

1

imglab

To speedup and simplify image labeling/ annotation process with multiple supported formats.
HTML
946
star
2

Stubmatic

Mock HTTP calls without coding. Designed specially for testing and testers.
JavaScript
130
star
3

nimn-spec

Just Data. Save up to 85% network bandwidth and storage.
88
star
4

nimnjs

JS implementation of nimn specification
JavaScript
45
star
5

cytorus

Cypress based Gherkin tests runner where you can run tests for a single story or route
JavaScript
21
star
6

fastify-xml-body-parser

Fastify plugin / module to parse XML payload / body into JS object
JavaScript
19
star
7

Grapes

Flexible Regular Expression
Java
19
star
8

detailed-xml-validator

Validate for XML schema and returns all the possible failures
JavaScript
14
star
9

StubbyDB

A nodejs based complete solution for maintaining the stubs for your project
JavaScript
11
star
10

nimnjs-schema-builder

Build schema from JS object or JSON to feed into nimnjs
JavaScript
4
star
11

cucumon

Gherkin like feature file parser with a dash of lemon
JavaScript
3
star
12

strnum

String to Number based on configuration
JavaScript
3
star
13

nimnjs-date-parser

compress date for nimnjs
JavaScript
2
star
14

ads

Promote your opensource project Free
2
star
15

common-fonts

Collection of mostly used fonts
HTML
2
star
16

stubby-db-test

This is the test repository to test stubby-db features
JavaScript
2
star
17

floating-round-button

Floating Round Button
HTML
2
star
18

comparejs

Compare features and performance of similar js libraries (not just stats)
JavaScript
2
star
19

riot-svg

Creating RIOT SVG transformable elements
HTML
2
star
20

cytorus-reporter

Provide various reporterting tools to process Cytorus result
JavaScript
2
star
21

fxp-ent

Fast XML Parser and HTML DOM Parser Enterprise edition
2
star
22

semver-split

A small and fast utility to split semver string in major minor patch version object
JavaScript
2
star
23

cytorus-boilerplate

Check this out to kick start with a Cytorus project
JavaScript
2
star
24

bexp

Boolean infix Expression/Notation Parser
JavaScript
1
star