[Top][All Lists]

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

Re: Problems with xml-parse-string

From: Lars Magne Ingebrigtsen
Subject: Re: Problems with xml-parse-string
Date: Wed, 22 Sep 2010 13:41:53 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux)

Lars Magne Ingebrigtsen <address@hidden> writes:

> There's very little if-ing necessary.  It's all very regular.  If the
> cdr of anything is a list, you can descend into it, and everything
> does have a cdr -- there are no atoms sprinkled here and there that you
> have to special-case all over the place...

To take a real example: Here's how to find all image urls in a HTML

(defun find-src (node)
  (let (src)
    (dolist (elem (cdr node))
       ((eq (car elem) 'img)
        (push (cdr (assq :src (cdr elem))) src))
       ((consp (cdr elem))
        (setq src (nconc (find-src elem) src)))))

(find-src (html-parse-string a))

It's, like, you need to know nothing about the DOM to traverse it, and
you can use the fast `assq' to get at what you want when not doing a
recursive descent...

And since I'm going to write a HTML renderer in Emacs Lisp, I think the
DOM should be as fast and as easy to work with as possible.  :-)

(domestic pets only, the antidote for overdose, milk.)
  address@hidden * Lars Magne Ingebrigtsen

reply via email to

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