(setf *print-case* :downcase) (defclass dom-element () ((tag-name :initarg :tag-name :accessor tag-name :initform nil) (text :initarg :text :accessor text :initform nil) (classes :initarg :classes :accessor classes :initform nil) (children :initarg :children :accessor children :initform nil) (father :initarg :father :accessor father :initform nil))) (defun father-child (father child) (setf (father child) father) (push child (children father))) (defparameter root (make-instance 'dom-element :tag-name 'html)) (defparameter body (make-instance 'dom-element)) (father-child root body) (defparameter div (make-instance 'dom-element)) (father-child body div) (setf (tag-name div) 'div) (setf (tag-name body) 'body) (setf (text div) "oh my cat is nice") (let ((nesting-value 0)) (defun render (element) (format t "~vt <~a" nesting-value (tag-name element)) (if (classes element) (format t " class=\"~{~a ~}\"" (classes element))) (format t ">~%") (if (text element) (format t "~vt ~a~%" (+ nesting-value 3) (text element))) (when (children element) (dolist (current (children element)) (incf nesting-value) (render current))) (format t "~vt ~%" nesting-value (tag-name element)) (decf nesting-value))) (format t "~%") (render root)