xml-rpc.el hacking

Posted on Jun 9, 2002

Here are the functions to mangle the new xml.el output back to a format that xml-rpc.el is more content to understand:

(defun xml-rpc-clean-string (s)
  (let ((new-string (replace-regexp-in-string "^[ t\n]+" "" s)))
    (if (string-equal "" new-string)
	nil new-string)))

(defun xml-rpc-clean (l)
  (cond ((listp l)
	 (let ((remain l)
	       elem (result nil))
	   (while l (let (tmp)
		      (setq elem (car l)
			    l (cdr l))
		      (cond ((stringp elem)
			     (if (setq tmp (xml-rpc-clean-string elem))
				 (append (list 'result)
					 (list tmp))))
			    ((listp elem)
			     (append (list result)
				     (list (xml-rpc-clean elem))))
			    (t (append (list result)
				       (list elem))))))
	((stringp l)
	 ;; will returning nil be acceptable ? (xml-rpc-clean-string elem))
	 (t l)))

When combined with:

  • using these functions in a couple of places (new version of xml-rpc.el will be available when it's cleaned up a little),

  • a patch to support "blogname" as well as "blogName" in the XML,

  • a patch to remove ^M characters from the XML,