1.0.5 • Published 7 months ago

markup2json v1.0.5

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

markup2json

Minified size Test coverage Monthly download

markup2json is a JavaScript library that provides an easy way to convert HTML and XML into JSON format. It uses the @xmldom/xmldom package to parse the input HTML/XML string and convert it into a JSON object. The library is designed to be lightweight, easy to use and compatible with both Node.js and web browsers.

Features

  • Malformed input validation
  • Supports HTML and XML
  • Supports Deno via NPM

Installation

To install markup2json, run the following command:

NPM

npm install markup2json

Yarn

yarn add markup2json

pnpm

pnpm add markup2json

Usage

import markup2json from "markup2json";
// import markup2json from "npm:markup2json"; // (for Deno)

const html = "<div class='container'><p>Hello, World!</p></div>";
const json = markup2json(html);

console.log(json);

Output

{
  "tag": "div",
  "attributes": {
    "class": "container"
  },
  "children": [
    {
      "tag": "p",
      "children": [
        {
          "tag": "#text",
          "text": "Hello, World!"
        }
      ]
    }
  ]
}

License

MIT License

1.0.5

7 months ago

1.0.4

8 months ago

1.0.2

9 months ago

1.0.1

11 months ago

1.0.3

9 months ago

1.0.0

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago