Socket
Book a DemoInstallSign in
Socket

rapid-xml-to-json

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rapid-xml-to-json

Fast, dependency-free XML-parser for parsing XML structures into JSON. Optimised for speed and low memory usage.

0.1.3
latest
Source
npmnpm
Version published
Weekly downloads
3
Maintainers
0
Weekly downloads
 
Created
Source

rapid-xml-to-json

rapid-xml-to-json is a fast, lightweight XML parser designed for simple hierarchical XML data.

Features

This library is built for performance and simplicity. Below is a summary of what it can and cannot do:

✅ Features

  • Parses well-formed XML into a nested JavaScript object.
  • Handles basic XML structures with child elements.
  • Sets attributes on elements ($attrs)
  • Supports CDATA sections.
  • Skips comments, processing instructions (<?...?>), and <!DOCTYPE> declarations.

❌ Limitations

  • Does not handle mixed content (text between and around child elements). (To be implemented)
  • Does not validate XML (assumes input is well-formed).

Installation

You can install the library via npm:

npm install rapid-xml-to-json

Usage

Here’s how you can use rapid-xml-to-json:

import { xlmToJson } from 'rapid-xml-to-json';

const xml = `
<root>
  <item>
    <![CDATA[Some content here]]>
  </item>
  <item>
    <subitem>Another piece of content</subitem>
  </item>
</root>
`;

const parsed = xmlToJson(xml);

console.log(parsed);
// Output:
// {
//   root: {
//     item: [
//       "Some content here",
//       { subitem: "Another piece of content" }
//     ]
//   }
// }

Performance

rapid-xml-to-json is optimized for speed and low memory usage, skipping some XML features to avoid overhead.

API

xmlToJson(xml: string): object

Parses a well-formed XML string into a JavaScript object.

Parameters

  • xml (string): The well-formed XML string to parse.

Returns

  • A nested JavaScript object representing the XML structure.

Benchmarks

Soon(tm)

Contributing

Contributions are welcome! If you encounter any issues or have suggestions for improvement, feel free to open an issue or a pull request.

License

This library is licensed under the MIT License. See the LICENSE file for more information.

Keywords

xml2json

FAQs

Package last updated on 08 Jan 2025

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.