评论者:bpeter
我发现了一个"解决方案"如下,并在(link: ^zip-xml-bug-descent.tgz)中可以看到。
`
(defn descent=
[tagname]
(fn [loc]
(filter #(and (zip/branch? %) (= tagname (:tag (zip/node %))))
(testing "使用 descent 选择内部名称"
(is (= "Inner"
(-> (zip-xml/xml1-> root :Root :Group (descent= :Group) :Name zip-xml/text)))))
`
It seems the first expression in {{tag=}} matching the element itself in the {{or}} expression is the problem in my case. I suspect it can be used to select the root element. Is there any other need for it?
`
(defn tag=
[tagname]
(fn [loc]
(or (= tagname (:tag (zip/node loc)))
(filter #(and (zip/branch? %) (= tagname (:tag (zip/node %))))
(zf/children-auto loc)))))
`
也许应该有一个 {{self}}谓词?