1.0.1 • Published 3 years ago

opml-to-json v1.0.1

Weekly downloads
333
License
MIT
Repository
github
Last release
3 years ago

opml-to-json Build Status

Convert OPML to JSON(JavaScript Object).

Installation

npm install opml-to-json

Usage

Example OPML file.

<?xml version="1.0" encoding="utf-8"?>
<opml version="1.0">
  <head>
    <title>title</title>
    <expansionState>0,2</expansionState>
  </head>
  <body>
    <outline text="H1">
      <outline text="H2 Text"/>
      <outline text="H2">
        <outline text="text"/>
      </outline>
    </outline>
    <outline text="H1 text"/>
  </body>
</opml>
import { opmlToJSON } from "opml-to-json";

const json = await opmlToJSON(xml);
const expected = {
    "title": "title",
    "children": [
        {
            "text": "H1", "children": [
                { "text": "H2 Text" },
                {
                    "text": "H2", "children": [
                        { "text": "text" }
                    ]
                }
            ]
        },
        { "text": "H1 text" }
    ]
};
assert.deepStrictEqual(json, expected);

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT