ちょっと息抜き GaucheでXMLから内容を抽出する
XPathが使えますよ(SXPath)。
(use rfc.http) (use sxml.ssax) (use sxml.sxpath) (let-values (((status head body) (http-get "zip.ricollab.jp" "/5340026"))) (let ((xml (call-with-input-string body (cut ssax:xml->sxml <> '((xhtml . "http://www.w3.org/1999/xhtml")))))) ; //xhtml:dd[@class = 'address'] ((sxpath '(// (xhtml:dd (@ (equal? (class "address")))))) xml)))
gosh> ((xhtml:dd (|@| (class "address")) (xhtml:a (|@| (href "/大阪府") (class "prefecture")) "大阪府") (xhtml:a (|@| (href "/大阪府/大阪市都島区") (class "city")) "大\ 阪市都島区") (xhtml:a (|@| (href "/大阪府/大阪市都島区/網島町") (class "town")) "網島町")))
括弧で目が痛い。。。まだまだ研鑽が足りんのか。