[plexippus-xpath-devel] interaction of plexippus and closure-html
Ivan Shvedunov
ivan4th at gmail.com
Sat Mar 7 15:24:46 UTC 2009
On Sat, Mar 7, 2009 at 5:51 PM, Andras Simon <szajmi at gmail.com> wrote:
> I'm trying to use plexippus with closure-html to search in possibly
> badly formed html. But I ran into the following:
>
> (defun show (xpath doc)
> (xpath:do-node-set (node (xpath:evaluate xpath doc))
> (format t "found element: ~A~%"
> (xpath-protocol:local-name node))))
>
>
> (show "/html" (cxml:parse "<html><head></head><body></body></html>"
> (stp:make-builder)))
> found element: html
> NIL
>
> as expected, but
>
> (show "/html" (chtml:parse #p"test.html" (stp:make-builder)))
> NIL
>
> Here test.html contains the same string that was given to cxml:parse
> above.
>
> Comparing the results of the two parse functions it looks like this
> may have something to do with namespaces, but I'm not sure.
>
> What am I missing?
>
Yes, you must specify namespace bindings using xpath:with-namespaces
around your xpath:evaluate call.
The output of closure-html uses XHTML namespace which is
http://www.w3.org/1999/xhtml
CL-USER> (xpath:map-node-set->list
#'stp:local-name
(xpath:with-namespaces ((nil "http://www.w3.org/1999/xhtml"))
(xpath:evaluate "/html" (chtml:parse "<html><body></body></html>"
(stp:make-builder)))))
("html")
Ivan
More information about the plexippus-xpath-devel
mailing list