chickadee » sxpath » sxml:xpath-expr

sxml:xpath-expr string #!rest ns-bindingprocedure

Returns a procedure that accepts an SXML node and returns #t if the node matches the string expression. This is an expression of type Expr, which is whatever you can put in a predicate (between square brackets after a node name).

The optional ns-binding argument is an alist of namespace bindings. It is used to map abbreviated namespace prefixes to full URI strings.

;; Does the node have a class attribute with "content" as value?
((sxml:xpath-expr "@class=\"content\"")
 '(div (@ (class "content")) (p "Lorem ipsum")))
 => #t

;; Does the node have a paragraph with string value of "Lorem ipsum"?
((sxml:xpath-expr "p=\"Lorem ipsum\"")
 '(div (@ (class "content")) (p "Lorem ipsum")))
 => #t

;; Does the node have a "p" child node with string value of "Blah"?
((sxml:xpath-expr "p=\"Blah\"")
 '(div (@ (class "content")) (p "Lorem ipsum")))
 => #f