anchor.diff:      (multiple-value-bind (body status headers)
           (do-http-request/retry uri
             :method :get :query q :external-format :utf-8)
  -      (parse-response body status headers))))
  +      (translate-result
  +       (parse-response body status headers)
  +       result-type))))
  +
  +(defun translate-result (lxml type)
  +  (ecase type
  +    ((:whole) lxml)
  +    ((:nodes) (extract-doc-nodes lxml))
  +    ((:alist) (mapcar #'doc-node->alist (extract-doc-nodes lxml)))))
  +
  +;; This woulb be a one-liner if we could use XPath, but I [SK] don't
  +;; want to depend on CL-XML just for that.
  +(defun extract-doc-nodes (lxml)
  +  (labels ((search-result (lxml)
  +             (cond ((not (consp lxml)) nil)
  +                   ((and (consp lxml) (consp (car lxml))
  +                         (eq (caar lxml) 'result)
  +                         (equal (cadr (member 'name (cdar lxml))) "response"))
  +                    (cdr lxml))             ;found
  +                   (t (dolist (node (cdr lxml))
  +                        (let ((r (search-result node)))
  +                          (when r (return-from extract-doc-nodes r))))))))
  +    (search-result lxml)))
  +
  +(defun doc-node->alist (node)
  +  (labels ((get-name (n)
  +             (intern (cadr (member 'name (cdar n))) :keyword))
  +           (get-value (n)
  +             (print n)
  +             (let ((type (if (consp (car n)) (caar n) (car n)))
  +                   (vals (cdr n)))
  +               (ecase type
  +                 ((str)     (car vals))
  +                 ((arr lis) (mapcar #'get-value vals))
  +                 ((int)     (parse-integer (car vals)))
  +                 ((float)   (let ((v (read-from-string (car vals))))
  +                              (unless (realp v)
  +                                (error "Invalid float number:" (car vals)))
  +                              v))
  +                 ((bool)    (not (equal (car vals) "false")))
  +                 ((date)    (parse-iso8601 (car vals)))))))
  +    (mapcar (lambda (n) (cons (get-name n) (get-value n))) (cdr node))))
  +
   
   ;;;
   ;;; Some utilities
  
positive.code: If OVERWRITE is true, an existing record with the same key field will be
  replaced with DOC, if any.
  
  Example:
    (solr-add solr '((id . 1234) (name . \"foo\")
                     (text . \"Lorem ipsum dolor sit amet, consectetur
     adipisicing elit, sed do eiusmod tempor incididunt ut labore et
     dolore magna aliqua.\"))
                   :commit t)
  
negative.code:     else (loop for (key . val) in rec do (render-field key val))))
  
  (defun render-field (key val)
    (if* (consp val)
      then (dolist (v val) (render-field key v))
      else ^((field @name key) @(render-value val))))
  
  (defun render-value (val)
    (etypecase val
      (number val)
      (boolean (xbool val))
      (string val)
      (symbol val)
      (date-time
  