Performing complicated XPath queries in Scala

前端 未结 5 1185
灰色年华
灰色年华 2021-01-04 08:14

What\'s the simplest API to use in scala to perform the following XPath queries on a document?

//s:Annotation[@type=\'attitude\']/s:Content/s:Parameter[@role         


        
5条回答
  •  猫巷女王i
    2021-01-04 09:13

    I would suggest using kantan.xpath:

     import kantan.xpath._
     import kantan.xpath.implicits._
    
     input.evalXPath[List[String]](xp"/annotation[@type='attitude']/content/parameter[@role='type' and not(text())]/@value")
    

    This yields:

    res1: kantan.xpath.XPathResult[List[String]] = Success(List(foobar))
    

提交回复
热议问题