From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lars Magne Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Re: Problems with xml-parse-string Date: Wed, 22 Sep 2010 13:41:53 +0200 Organization: Programmerer Ingebrigtsen Message-ID: References: <87pqw6d7nz.fsf@stupidchicken.com> <87zkvaiked.fsf@stupidchicken.com> <87vd5ymptn.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1285156997 5736 80.91.229.12 (22 Sep 2010 12:03:17 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 22 Sep 2010 12:03:17 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 22 14:03:16 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OyO2e-0004IC-3e for ged-emacs-devel@m.gmane.org; Wed, 22 Sep 2010 14:03:16 +0200 Original-Received: from localhost ([127.0.0.1]:40708 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OyNie-0006bT-Fk for ged-emacs-devel@m.gmane.org; Wed, 22 Sep 2010 07:42:36 -0400 Original-Received: from [140.186.70.92] (port=41813 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OyNiH-0006YW-6X for emacs-devel@gnu.org; Wed, 22 Sep 2010 07:42:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OyNi9-0006IM-NA for emacs-devel@gnu.org; Wed, 22 Sep 2010 07:42:10 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:47913) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OyNi9-0006IA-AN for emacs-devel@gnu.org; Wed, 22 Sep 2010 07:42:05 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OyNi5-0003Ht-ML for emacs-devel@gnu.org; Wed, 22 Sep 2010 13:42:01 +0200 Original-Received: from cm-84.215.34.171.getinternet.no ([84.215.34.171]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 22 Sep 2010 13:42:01 +0200 Original-Received: from larsi by cm-84.215.34.171.getinternet.no with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 22 Sep 2010 13:42:01 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 34 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: cm-84.215.34.171.getinternet.no Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAHlBMVEVLIARmJwoqFAAkEACd diQ0CQExFwE9GwInEwBOHQXb9tWfAAACUElEQVQ4jWWUsW7bMBCG6aKIkU0sDLvZ0ktBqFtrDVE3 KyDsB+gL2KxxymijhtiOlYCCYwx00dv2P1KOneZgyOJ94s/j8ZeUvoii+GJtZSfW2gcliWPK90Xx +QyK/yIQMTORgG8vQEuGjaPXM1qK8QqUIUCNDEDoTg8jKUOZxKrANRL8G6I2CAgAJCVIcAqiEEfK YOBi3iOaOIhSGAOZlD+RAfha0vsbpUZ25pMeK+9/pWf/Wq0tQHMCe1shveuPtprYSo1907AzAGhZ Nr5GD6V3FX5xDgCGN3jcxqZKzBLYRdBre4pq7C9AEkqxEK06rhGVziE7A/DHp+vJCyB78UpKHdkL JW1XwwzvDygrHXumVDVaYZE6tmTn/aLv+yeF8IdxWkNKq/1+lrhcV7KPBLg++Gbobe0nfAac8Tm2 S5aqnNzfTqVvOAo5GK4ikLOjjzianJJxHG3jzgnPuiwPXdmVba7FCGY6AF4/kICQh/tlgHk2EUBr 68RQYrbidwf33l6hu7JGRV0yXUgmNRE43ixpcGP8K4NZA6C0Q0PPUvFKmCKGWzDAJrswvFFiUSjR RmffkUqCJdHaQ+rg8nCVcoMicb0CWLm8SwW1ca2yhLxWvH1HuWTnoeU6kvAHnVQ8gVIXZdqZ7uVe ZqxVvXSUR0BG75dvcI+mYB9buP4ZbLNpPry4KsspxDW61ui3emruElHv8Zam8ufR1dpmoYYn1Af0 7x7OhUkBKtVw+RgCN+rTXdHdO/auKL4e9bTe/VyPlV08Xn4A5tT/eB68+jKc4h8qGFCeoM4P9QAA AABJRU5ErkJggg== Mail-Copies-To: never X-Now-Playing: Zazou, Bikaye & Cy1's _Noir et Blanc_: "Eh! Yaye" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:CSh+7PEEzGtmW+tsruZRV4i5Hl4= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:130606 Archived-At: Lars Magne Ingebrigtsen 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.) larsi@gnus.org * Lars Magne Ingebrigtsen