AtomFeed.parse constructor
AtomFeed.parse(
- String xmlString
Implementation
factory AtomFeed.parse(String xmlString) {
final document = XmlDocument.parse(xmlString);
XmlElement feedElement;
try {
feedElement = document.findElements('feed').first;
} on StateError {
throw ArgumentError('feed not found');
}
return AtomFeed(
id: findElementOrNull(feedElement, 'id')?.text,
title: findElementOrNull(feedElement, 'title')?.text,
updated: findElementOrNull(feedElement, 'updated')?.text,
items: feedElement
.findElements('entry')
.map((element) => AtomItem.parse(element))
.toList(),
links: feedElement
.findElements('link')
.map((element) => AtomLink.parse(element))
.toList(),
authors: feedElement
.findElements('author')
.map((element) => AtomPerson.parse(element))
.toList(),
contributors: feedElement
.findElements('contributor')
.map((element) => AtomPerson.parse(element))
.toList(),
categories: feedElement
.findElements('category')
.map((element) => AtomCategory.parse(element))
.toList(),
generator:
AtomGenerator.parse(findElementOrNull(feedElement, 'generator')),
icon: findElementOrNull(feedElement, 'icon')?.text,
logo: findElementOrNull(feedElement, 'logo')?.text,
rights: findElementOrNull(feedElement, 'rights')?.text,
subtitle: findElementOrNull(feedElement, 'subtitle')?.text,
);
}