Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fast-xml-parser

Package Overview
Dependencies
Maintainers
1
Versions
136
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-xml-parser

Validate XML, Parse XML, Build XML without C/C++ based libraries

  • 4.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24M
increased by0.67%
Maintainers
1
Weekly downloads
 
Created

What is fast-xml-parser?

The fast-xml-parser npm package is a fast and powerful XML parser and validator that can convert XML to a JavaScript object, JSON, or a traversable JS object. It can also convert a JS object to XML. It is designed to be very fast and efficient, and it provides various options to control the XML parsing and validation process.

What are fast-xml-parser's main functionalities?

XML to JSON Conversion

Converts XML data to a JSON object. The 'parse' function takes an XML string and optional options object, and returns a JSON representation of the XML.

const { parse } = require('fast-xml-parser');
const xmlData = '<note><to>User</to><from>Library</from><heading>Reminder</heading><body>Don't forget to subscribe.</body></note>';
const options = {};
const jsonObj = parse(xmlData, options);

JSON to XML Conversion

Converts a JSON object to an XML string. The 'j2xParser' constructor takes an options object, and the 'parse' method converts the JSON object to an XML string.

const { j2xParser } = require('fast-xml-parser');
const parser = new j2xParser({});
const jsonObj = { note: { to: 'User', from: 'Library', heading: 'Reminder', body: 'Don't forget to subscribe.' } };
const xmlData = parser.parse(jsonObj);

XML Validation

Validates the XML string. The 'validate' function checks if the given XML string is well-formed and returns a validation result.

const { validate } = require('fast-xml-parser');
const xmlData = '<note><to>User</to><from>Library</from></note>';
const validationResult = validate(xmlData);

Traversable Object Creation

Creates a traversable JavaScript object from XML. The 'XMLParser' constructor creates a parser instance, and the 'parse' method converts the XML string into a traversable JS object.

const { XMLParser } = require('fast-xml-parser');
const xmlData = '<note><to>User</to><from>Library</from></note>';
const parser = new XMLParser();
const traversableObject = parser.parse(xmlData);

Other packages similar to fast-xml-parser

Keywords

FAQs

Package last updated on 03 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc