Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Recursive Parse

 [1/3] from: belkasri:1stlegal at: 10-Jun-2002 8:51


I am kind of new to REBOL, I wrote these lines to get the latest news from www.cnn.com <http://www.cnn.com/> , so far I can get the first line in the news table, but I don't know how to make my parse recursive to get all the news lines in the table. Here is the code: page: read http://www.cnn.com/index.html parse page [thru "Other Top News" copy news-table to "</table>"] parse news-table [to "<a" thru ">" copy newsline to "</a>"] print newsline --Abdel.

 [2/3] from: joel:neely:fedex at: 10-Jun-2002 10:40


Hi, Abdel, Abdel Belkasri wrote:
> I am kind of new to REBOL, I wrote these lines to get the latest news from > www.cnn.com <http://www.cnn.com/> , so far I can get the first line in the
<<quoted lines omitted: 4>>
> parse news-table [to "<a" thru ">" copy newsline to "</a>"] > print newsline
I suggest iteration instead of recursion for this task: parse news-table [ any [ to "<a" thru ">" copy newsline to "</a>" (print newsline) ] to end ] which, this morning at 10:40 CT (US) gives: U.S. hostage survivor seeks justice Video Colorado fire burns 500 acres an hour Video Rumsfeld: Iraq 'lying' about biological weapons Afghan loya jirga meeting delayed Video Sunset eclipse hits tonight Where to watch U.S. ties S. Korea in Cup Standings == true Note the addition of TO END after the part that you expect to exhaust the relevant data. That allows you to test the true/false result of PARSE for success or failure. -jn-

 [3/3] from: belkasri::1stlegal::com at: 10-Jun-2002 11:52


Thanks Joel, it worked like a charm! --Abdel.

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted