let xml_of_item ~date_fmt i =
  Element ("item", [],
           (List.flatten
              [ opt_element i.item_title "title" ;
                opt_element i.item_link "link" ;
                opt_element i.item_desc "description" ;
                opt_element
                  (match i.item_pubdate with
                    None -> None
                  | Some d ->
                      err_date d;
                      Some (Rss_date.format ~fmt: date_fmt d))
                  "pubDate" ;
                opt_element i.item_author "author" ;
                xmls_of_categories i.item_categories ;
                opt_element i.item_comments "comments" ;
                xmls_of_enclosure_opt i.item_enclosure ;
                xmls_of_guid_opt i.item_guid ;
                xmls_of_source_opt i.item_source ;
              ]
           )
          )