Hi Henrik,

> The problem is using from in combination with till repeatedly to parse
> input in order to for instance get at the contents of the <item></tem>
> elements, there is a twist though, the contents can contain more
> markup so a check is needed every time till encounters for instance <,
> if that one is to be used as a stop char.

This is indeed a bit tedious, because we would need to manually collect
strings and match them until the proper patterns are found.


But before we start doing that: I'm wondering why this should be
necessary. Can't we just just use the 'xml' function? It was written for
that purpose after all (though it is also based on 'from' and 'till'):

   (load "lib/xml.l")
   (setq Lst (in "rss.xml" (and (xml?) (xml))))

Now 'Lst' contains the whole XML tree, which can be handled easily with
Lisp functions.


For example, to collect all <item> expressions nested somewhere in that
list, you could use 'fish'

   (fish '((L) (== 'item (car L))) Lst)

Actually, the sample "rss.xml" you've attached does not seem to contain
any 'item' tags. But if I try 'author'

   (fish '((L) (== 'author (car L))) Lst)

I get a long result list.

To inspect it conveniently, I usually do

   (more (fish '((L) (== 'author (car L))) Lst) pretty)

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:[email protected]?subject=unsubscribe

Reply via email to