Skip to content

Instantly share code, notes, and snippets.

@priyadarshan
Created February 23, 2017 12:33
Show Gist options
  • Save priyadarshan/939c1df7df24835d54d68e5efee77220 to your computer and use it in GitHub Desktop.
Save priyadarshan/939c1df7df24835d54d68e5efee77220 to your computer and use it in GitHub Desktop.
Generate a sitemap 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"))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment