How can I do a sitemap using common lisp?
We are going to using cxml library.
We are going to using cxml library.
(defun generate-sitemap (urls)
"Creates the sitemap file"
(with-open-file (file "/tmp/sitemap.xml"
:direction :output
:element-type :default
:if-exists :supersede)
(cxml:with-xml-output (cxml:make-octet-stream-sink file :indentation 1 :canonical nil)
(cxml:with-element "urlset"
(cxml:attribute "xmlns" "http://www.sitemaps.org/schemas/sitemap/0.9")
;; create the tags
(dolist (item urls)
(cxml:with-element "url"
(cxml:with-element "loc"
(cxml:text item))
(cxml:with-element "changefreq"
(cxml:text "daily"))))))))
#lisp