AtomFeed.parse constructor
AtomFeed.parse(
- String xmlString
Parse constructor for the AtomFeed class, used when 'parsing' a feed
Implementation
factory AtomFeed.parse(String xmlString) {
final document = XmlDocument.parse(xmlString);
final feedElement = document.findElements('feed').firstOrNull;
if (feedElement == null) {
throw ArgumentError('feed not found');
}
return AtomFeed(
id: feedElement.findElements('id').firstOrNull?.innerText,
title: feedElement.findElements('title').firstOrNull?.innerText,
updated: parseDateTime(
feedElement.findElements('updated').firstOrNull?.innerText,),
items: feedElement.findElements('entry').map(AtomItem.parse).toList(),
links: feedElement.findElements('link').map(AtomLink.parse).toList(),
authors:
feedElement.findElements('author').map(AtomPerson.parse).toList(),
contributors: feedElement
.findElements('contributor')
.map(AtomPerson.parse)
.toList(),
categories:
feedElement.findElements('category').map(AtomCategory.parse).toList(),
generator: feedElement
.findElements('generator')
.map(AtomGenerator.parse)
.firstOrNull,
icon: feedElement.findElements('icon').firstOrNull?.innerText,
logo: feedElement.findElements('logo').firstOrNull?.innerText,
rights: feedElement.findElements('rights').firstOrNull?.innerText,
subtitle: feedElement.findElements('subtitle').firstOrNull?.innerText,
);
}