Find all nodes that have an attribute that matches a certain value with scala

前端 未结 5 1046
遥遥无期
遥遥无期 2021-02-08 04:00

I saw the following example on Nabble, where the goal was to return all nodes that contain an attribute with an id of X that contains a value Y:

//find all nodes         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-08 04:27

    def nodeHasValue(node:Node,value:String) = node.attributes.value != null && node.attributes.value.contains(value)
    
    (x \\ "_").filter( nodeHasValue(_,"test"))
    

提交回复
热议问题