[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error in xml.el documentation

From: Lennart Borgman (gmail)
Subject: Re: Error in xml.el documentation
Date: Sat, 23 Feb 2008 02:18:50 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20071031 Thunderbird/ Mnenhy/

Jason Rumney wrote:
Lennart Borgman (gmail) wrote:

This one is correct. The functions mentioned return a list of nodes. In the case of xml-parse-region at least, there can be more than one node at the top level of the returned list.

Thanks, I did not think of that case.

But it seems I was wrong. xml-parse-region throws an error if the region does not contain well-formed XML with a single top-level node. So although the functions all return a list, they all always return a list of one.

Would something like this fit in xml.el:

(defun freemind-get-child (parent path)
  (message "freemind-get-child %s %s" parent path)
  (let* ((childs (cddr parent))
         (step (car path))
         (step-node (if (listp step) (car step) step))
         (step-num  (if (listp step) (cdr step) 1))
         (path-tail (cdr path))
         (path-child (catch 'path-child
                       (dolist (child childs)
                         (when (and (not (stringp child))
                                    (eq step-node (car child)))
                           (when (= 1 step-num)
                             (throw 'path-child child))
                           (setq step-num (1- step-num)))))))
    (if path-tail
        (freemind-get-child path-child path-tail)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]