opml-to-json
v1.0.1
Published
convert opml to json.
Downloads
339
Readme
opml-to-json
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
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
License
MIT