1.0.8 • Published 12 months ago

xml2json-es v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

xml2json-es

xml2json-es is a JavaScript library that allows you to convert XML data to JSON format. It can be used in both browser environments and Node.js.

Features

  • Convert XML to JSON
  • Handle XML data with nested elements and attributes
  • Support for browser and Node.js environments
  • Lightweight and easy to use

Installation

You can install xml2jsonES using npm:

npm install xml2jsones

Usage

Browser
import xml2jsonES from 'xml2json-es';
import axios from 'axios';

const RSS_URL = ``;

const fetchData = async () => {
  const response = await axios.get(RSS_URL);
  const xmlString = response.data;
  const parser = new window.DOMParser();
  const xml = parser.parseFromString(xmlString, "text/html");
  const json = xml2jsonES(xml, true);
};

fetchData();
Node.js
const xml2jsonES = require('xml2json-es');
const axios = require('axios');

const RSS_URL = ``;

const fetchData = async () => {
  const response = await axios.get(RSS_URL);
  const xmlString = response.data;
  const parser = new DOMParser();
  const xml = parser.parseFromString(xmlString, "text/html");
  const json = xml2jsonES(xml, true);
};

fetchData();

API

xml2jsonES(element: Element | string | Object, json?: boolean): string | object Converts XML data to JSON format.

  • element (required): The XML element or string to convert to JSON.
  • json (optional): If set to true, the function returns the JSON as a string. Default is - false, which returns the JSON as an object.

License

MIT

1.0.8

12 months ago

1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago

0.0.1

12 months ago