atomparser 0.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 0

atomparser

A Dart library for parsing Atom feeds.

Inspired by xqwzts/feedparser.

Usage

import 'package:atomparser/atomparser.dart';

void main() {
  AtomFeed feed = parse(r'''
    <?xml version="1.0" encoding="utf-8"?>
    <feed xmlns="http://www.w3.org/2005/Atom">

      <title>Example Feed</title>
      <link href="http://example.org/"/>
      <updated>2003-12-13T18:30:02Z</updated>
      <author>
        <name>John Doe</name>
      </author>
      <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>

      <entry>
        <title>Atom-Powered Robots Run Amok</title>
        <link href="http://example.org/2003/12/13/atom03"/>
        <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
        <updated>2003-12-13T18:30:02Z</updated>
        <summary>Some text.</summary>
      </entry>

    </feed>
  ''');

  print(feed);

  // Output:
  //      id: urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6
  //      title: Example Feed
  //      updated: 2003-12-13T18:30:02Z
  //      authors: [
  //        name: John Doe
  //        uri: null
  //        email: null
  //      ]
  //      links: [
  //        href: http://example.org/
  //        rel: null
  //        type: null
  //        hreflang: null
  //        title: null
  //        length: null
  //      ]
  //      category: null
  //      icon: null
  //      logo: null
  //      rights: null
  //      subtitle: null
  //      entries: [
  //        id: urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a
  //        title:  text: Atom-Powered Robots Run Amok
  //                type: null
  //        updated: 2003-12-13T18:30:02Z
  //        author: null
  //        content: null
  //          link: href: http://example.org/2003/12/13/atom03
  //            rel: null
  //            type: null
  //            hreflang: null
  //          title: null
  //          length: null
  //          summary: text: Some text.
  //                   type: null
  //        category: null
  //        published: null
  //        rights: null
  //      ]
}

Strict mode

As long as the input string provided is a valid XML string, atomparser will attempt to parse it and return a AtomFeed object. In strict mode atomparser instead throws ArgumentErrors for missing mandatory fields [as defined by the Atom spec]. This is useful for testing feeds to ensure they meet the spec, but impractical when dealing with feeds not under your control.

AtomFeed feed = parse(xmlString, strict: true);

0.0.1

  • Initial version.

example/example.dart

import 'package:atomparser/atomparser.dart';

void main() {
  AtomFeed feed = parse(r'''
    <?xml version="1.0" encoding="utf-8"?>
    <feed xmlns="http://www.w3.org/2005/Atom">

      <title>Example Feed</title>
      <link href="http://example.org/"/>
      <updated>2003-12-13T18:30:02Z</updated>
      <author>
        <name>John Doe</name>
      </author>
      <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>

      <entry>
        <title>Atom-Powered Robots Run Amok</title>
        <link href="http://example.org/2003/12/13/atom03"/>
        <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
        <updated>2003-12-13T18:30:02Z</updated>
        <summary>Some text.</summary>
      </entry>

    </feed>
  ''');

  print(feed);

  // Output:
  //      id: urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6
  //      title: Example Feed
  //      updated: 2003-12-13T18:30:02Z
  //      authors: [
  //        name: John Doe
  //        uri: null
  //        email: null
  //      ]
  //      links: [
  //        href: http://example.org/
  //        rel: null
  //        type: null
  //        hreflang: null
  //        title: null
  //        length: null
  //      ]
  //      category: null
  //      icon: null
  //      logo: null
  //      rights: null
  //      subtitle: null
  //      entries: [
  //        id: urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a
  //        title:  text: Atom-Powered Robots Run Amok
  //                type: null
  //        updated: 2003-12-13T18:30:02Z
  //        author: null
  //        content: null
  //          link: href: http://example.org/2003/12/13/atom03
  //            rel: null
  //            type: null
  //            hreflang: null
  //          title: null
  //          length: null
  //          summary: text: Some text.
  //                   type: null
  //        category: null
  //        published: null
  //        rights: null
  //      ]
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  atomparser: ^0.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:atomparser/atomparser.dart';
  
Version Uploaded Documentation Archive
0.0.1 Mar 22, 2018 Go to the documentation of atomparser 0.0.1 Download atomparser 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Maintenance issues and suggestions

Running dartdoc failed. (-10 points)

Make sure dartdoc runs without any issues.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.3 <2.0.0