toXmlDocument method

XmlDocument toXmlDocument()

Implementation

XmlDocument toXmlDocument() {
  final builder = XmlBuilder();
  builder.element("rss", attributes: {
    "version": "2.0",
  }, nest: () {
    builder.element("channel", nest: () {
      if (title != null) {
        builder.element("title", nest: title!);
      }

      if (description != null) {
        builder.element("description", nest: description!);
      }

      if (link != null) {
        builder.element("link", nest: link!);
      }

      if (language != null) {
        builder.element("language", nest: language!);
      }

      if (pubDate != null) {
        builder.element("pubDate", nest: pubDate!);
      }

      if (lastBuildDate != null) {
        builder.element("lastBuildDate", nest: lastBuildDate!);
      }

      if (docs != null) {
        builder.element("docs", nest: docs);
      }

      for (final item in items) {
        item.buildXml(builder);
      }
    });

    // TODO: add all remaining properties.
  });

  return builder.buildDocument();
}