>> h-6ren">
gpt4 book ai didi

xml - HXT——什么是 "deep"?

转载 作者:数据小太阳 更新时间:2023-10-29 02:02:36 28 4
gpt4 key购买 nike

我花了很多时间来弄清楚如何使用 HXT。我一直反对使用 deep 的示例。 deep 有什么作用?

例如,this code具有以下内容:

atTag tag = deep (isElem >>> hasName tag)

Another example:

-- case-insensitive tag matching
atTagCase tag = deep (isElem >>> hasNameWith ((== tag') . upper . localPart))
where tag' = upper tag
upper = map toUpper

最佳答案

http://hackage.haskell.org/packages/archive/hxt/latest/doc/html/Control-Arrow-ArrowTree.html#v:deep

deep :: Tree t => a (t b) c -> a (t b) cSource

recursively searches a whole tree for subtrees, for which a predicate holds. The search is performed top down. When a tree is found, this becomes an element of the result list. The tree found is not further examined for any subtress, for which the predicate also could hold. See multi for this kind of search.

example: deep isHtmlTable selects all top level table elements in a document (with an appropriate definition for isHtmlTable) but no tables occuring within a table cell.

您可以通过 Hoogle 找到给定函数名称或类型签名的文档或 Hayoo!


基本上,如果 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>当走进树时,(isElem >>> hasName tag) tree将返回一个空列表,因为树的根是 <p> , 不是 <strong>

关于xml - HXT——什么是 "deep"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3899365/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com