I'm trying to search HTML using the cxml-stp package, and failing dismally.
* (cxml:parse "<html><body><table><tr><td/></tr><tr><td/></tr></table></body></html>" (stp:make-builder))
#.(CXML-STP-IMPL::DOCUMENT
:CHILDREN '(#.(CXML-STP:ELEMENT
#| :PARENT of type DOCUMENT |#
:CHILDREN '(#.(CXML-STP:ELEMENT
#| :PARENT of type ELEMENT |#
:CHILDREN '(#.(CXML-STP:ELEMENT
#| :PARENT of type ELEMENT |#
:CHILDREN '(#.(CXML-STP:ELEMENT
#| :PARENT of type ELEMENT |#
:CHILDREN '(#.(CXML-STP:ELEMENT
#| :PARENT of type ELEMENT |#
:LOCAL-NAME "td"))
:LOCAL-NAME "tr")
开发者_如何学Go #.(CXML-STP:ELEMENT
#| :PARENT of type ELEMENT |#
:CHILDREN '(#.(CXML-STP:ELEMENT
#| :PARENT of type ELEMENT |#
:LOCAL-NAME "td"))
:LOCAL-NAME "tr"))
:LOCAL-NAME "table"))
:LOCAL-NAME "body"))
:LOCAL-NAME "html")))
* (stp:find-recursively (stp:of-name "td") document)
NIL
* (stp:filter-recursively (stp:of-name "td") document)
NIL
I'm not quite sure what I'm doing wrong here. The return value of cxml:parse seems entirely sane, which leads me to believe I'm invoking stp:find-recursively and stp:filter-recursively wrongly.
Could someone please point me in the right direction? The docs say that this should work:
(stp:filter-recursively (stp:of-name "foo") node)
FWIW, I'm loading all the packages my app needs through Quicklisp:
(ql:quickload '("drakma" "closure-html" "cxml-stp"))
Works for me:
CL-USER> (stp:filter-recursively (stp:of-name "td") (cxml:parse "<html><body><table><tr><td/></tr><tr><td/></tr></table></body></html>" (stp:make-builder)))
(#.(CXML-STP:ELEMENT #| :PARENT of type ELEMENT |# :LOCAL-NAME "td")
#.(CXML-STP:ELEMENT #| :PARENT of type ELEMENT |# :LOCAL-NAME "td"))
精彩评论