RosettaCodeData/Task/XML-Output/Common-Lisp/xml-output-1.lisp

11 lines
592 B
Common Lisp

(defun write-xml (characters lines &optional (out *standard-output*))
(let* ((doc (dom:create-document 'rune-dom:implementation nil nil nil))
(chars (dom:append-child doc (dom:create-element doc "Characters"))))
(map nil (lambda (character line)
(let ((c (dom:create-element doc "Character")))
(dom:set-attribute c "name" character)
(dom:append-child c (dom:create-text-node doc line))
(dom:append-child chars c)))
characters lines)
(write-string (dom:map-document (cxml:make-rod-sink) doc) out)))