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

[REBOL] Re: How to properly parse HTML and XHTML Meta Tags

From: christian::ensel::gmx::de at: 12-Sep-2008 9:42

Hi Von, in your special case, it doesn't seem to be necessary to go thru the > or /> hassle, if you rely on " as a delimiter. But keep in mind that in many, many cases the solution below as well as yours will fail. E.g. in cases where the content and name attributes are given in reverse order, which is valid HTML, too. However, have a look at the following PARSE-METATAGS. HTH, Christian ------------------------------------------------------------------------ parse-metatags: func [page [url!] /local title keywords description] [ page: read parse page [thru <title> copy title to </title>] parse/all page [thru {<meta name="keywords" content="} copy keywords to {"}] parse/all page [thru {<meta name="description" content="} copy description to {"}] foreach keyword keywords: parse/all any [keywords ""] "," [trim keyword] reduce [ 'title title 'keywords keywords 'description description ] ]
>> parse-metatags
== [ title "REBOL Technologies" keywords ["REBOL" "Web 3.0" "Web 2.0" "programming" "Internet" software "domain specific language" "di stributed computing" "collaboration" "operating systems" "development" rebel ] description {REBOL: a Web 3.0 language and system based on new lightweight computing methods. Site inclu des products, downloads, documentation, and support.} ] schrieb: