opml 0.1.0 copy "opml: ^0.1.0" to clipboard
opml: ^0.1.0 copied to clipboard

outdated

A Dart package for parsing and building OPML documents.

opml #

A Dart package for parsing and building OPML documents.

Installing #

Import the package into your Dart code using:

import 'package:opml/opml.dart';

Examples #

Parsing XML #

To parse XML input, use the OpmlDocument.parse(String xmlString) factory:

final xmlString = """
<?xml version='1.0' encoding='UTF-8' ?>
<opml version="1.0">
  <head>
    <title>Example OPML Export</title>
  </head>
  <body>
    <outline text="World" title="World">
      <outline type="rss" text="BBC News - World" xmlUrl="http://feeds.bbci.co.uk/..." />
      <outline type="rss" text="World news | The Guardian" xmlUrl="http://feeds.guardian.co.uk/..." />
    </outline>
    <outline text="Uncategorized" title="Uncategorized" />
  </body>
</opml>
""";

final opml = OpmlDocument.parse(xmlString);

Converting to XML #

You can convert an OpmlDocument object into XML by calling toXmlString() on it.

final body = <OpmlOutline>[
  OpmlOutline(
    text: 'World',
    title: 'World',
    children: [
      OpmlOutline(
        type: 'rss',
        text: 'BBC News - World',
        title: 'BBC News - World',
        xmlUrl: 'http://feeds.bbci.co.uk/news/world/rss.xml',
      ),
      OpmlOutline(
        type: 'rss',
        text: 'World news | The Guardian',
        title: 'World news | The Guardian',
        xmlUrl: 'http://feeds.guardian.co.uk/theguardian/world/rss',
      ),
    ],
  ),
  OpmlOutline(
    text: 'Uncategorized',
    title: 'Uncategorized',
  ),
];

final opml = OpmlDocument(
  head: OpmlHead(
    title: 'Example OPML Export',
  ),
  body: body,
);

final xml = opml.toXmlString(
  pretty: true,
);

print(xml);

License #

MIT

5
likes
0
pub points
73%
popularity

Publisher

unverified uploader

A Dart package for parsing and building OPML documents.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

meta, xml

More

Packages that depend on opml