RssItem.parse constructor

RssItem.parse(
  1. XmlElement element
)

Factory method to create an RssItem object from an XmlElement.

This method parses the element and extracts the relevant information from it to create an RssItem object and returns it.

The extracted information includes the title, description, link, categories, GUID, publication date, author, comments, source, content, media, enclosure, Dublin Core metadata, iTunes metadata, podcast metadata, and custom namespace metadata.

Implementation

factory RssItem.parse(XmlElement element) {
  return RssItem(
    title: element.findElements('title').firstOrNull?.innerText,
    description: element.findElements('description').firstOrNull?.innerText,
    link: element.findElements('link').firstOrNull?.innerText,
    categories: element
        .findElements('category')
        .map((e) => RssCategory.parse(e))
        .toList(),
    guid: element.findElements('guid').firstOrNull?.innerText,
    pubDate:
        parseDateTime(element.findElements('pubDate').firstOrNull?.innerText),
    author: element.findElements('author').firstOrNull?.innerText,
    comments: element.findElements('comments').firstOrNull?.innerText,
    source: element
        .findElements('source')
        .map((e) => RssSource.parse(e))
        .firstOrNull,
    content: element
        .findElements('content:encoded')
        .map((e) => RssContent.parse(e))
        .firstOrNull,
    media: Media.parse(element),
    enclosure: element
        .findElements('enclosure')
        .map((e) => RssEnclosure.parse(e))
        .firstOrNull,
    dc: DublinCore.parse(element),
    itunes: Itunes.parse(element),
    podcast: PodcastItem.parse(element),
    customNamespace: CustomNamespace.parse(element),
  );
}