解决方案
deep :: Tree t => a (t b) c -> a (t b) cSource
递归地搜索整棵树上的子树,为此谓词所持的子树。搜索是自上而下的。当找到树时,这将成为结果列表的元素。没有进一步检查发现的树的任何亚文明,谓词也可以持有。看
multi
对于这种搜索。例子:
deep isHtmlTable
选择文档中的所有顶级表元素(具有适当的定义isHtmlTable
),但在表单元格中没有表。
基本上,如果XML树就像
<p>
<strong id="a">
<em id="b">
<strong id="c">
foo
</strong>
</em>
</strong>
<ins id="d">
<strong id="e">
bar
</strong>
<em id="f">
baz
</em>
</ins>
</p>
deep (isElem >>> hasName "strong") tree
将返回列表
<strong id="a">
<strong id="e">
因为我们可以找到这两个 <strong>
S走进树时, (isElem >>> hasName tag) tree
将返回一个空列表,因为树的根是 <p>
, ,不是 <strong>
不隶属于 StackOverflow