[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
document:
(defun find-src (node)
(let (src)
(dolist (elem (cdr node))
(cond
((eq (car elem) 'img)
(push (cdr (assq :src (cdr elem))) src))
((consp (cdr elem))
(setq src (nconc (find-src elem) src)))))
src))
(find-src (html-parse-string a))
=>
("http://feeds.feedburner.com/~r/Slashdot/slashdot/~4/ObrTJGt5o5g"
"http://feedads.g.doubleclick.net/~at/dM87odHHTwmp1SgHU6CIgmtDAvA/1/di"
"http://feedads.g.doubleclick.net/~at/dM87odHHTwmp1SgHU6CIgmtDAvA/0/di"
"http://da.feedsportal.com/r/78871208090/u/49/f/530758/c/32909/s/234625720/a2.img"
"http://slashdot.feedsportal.com/c/32909/f/530758/s/dfc1ab8/mf.gif"
"http://a.fsdn.com/sd/twitter_icon_large.png"
"http://a.fsdn.com/sd/facebook_icon_large.png")
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
- Re: Problems with xml-parse-string, (continued)
- Re: Problems with xml-parse-string, Chad Brown, 2010/09/15
- Re: Problems with xml-parse-string, Chong Yidong, 2010/09/21
- Re: Problems with xml-parse-string, Leo, 2010/09/21
- Re: Problems with xml-parse-string, Chong Yidong, 2010/09/21
- Re: Problems with xml-parse-string, Chong Yidong, 2010/09/21
- Re: Problems with xml-parse-string, Stefan Monnier, 2010/09/22
- Re: Problems with xml-parse-string, Lars Magne Ingebrigtsen, 2010/09/22
- Re: Problems with xml-parse-string, Lars Magne Ingebrigtsen, 2010/09/22
- Re: Problems with xml-parse-string, Leo, 2010/09/22
- Re: Problems with xml-parse-string, Lars Magne Ingebrigtsen, 2010/09/22
- Re: Problems with xml-parse-string,
Lars Magne Ingebrigtsen <=
- Re: Problems with xml-parse-string, Wojciech Meyer, 2010/09/22
- Re: Problems with xml-parse-string, Lars Magne Ingebrigtsen, 2010/09/22
- Re: Problems with xml-parse-string, Wojciech Meyer, 2010/09/22
- Re: Problems with xml-parse-string, Lars Magne Ingebrigtsen, 2010/09/22
- Re: Problems with xml-parse-string, Wojciech Meyer, 2010/09/22
- Re: Problems with xml-parse-string, Lars Magne Ingebrigtsen, 2010/09/22
- Re: Problems with xml-parse-string, Wojciech Meyer, 2010/09/22
- Re: Problems with xml-parse-string, Lars Magne Ingebrigtsen, 2010/09/22
- Re: Problems with xml-parse-string, Leo, 2010/09/22
- Re: Problems with xml-parse-string, Lars Magne Ingebrigtsen, 2010/09/22