评论者:bpeter
我发现了一个 "替代方案",如下所示,并在 (链接:^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}} 判断子句?