"info.henix" %% "ssoup" % "0.5"
- DO NOT use v0.3
import henix.ssoup.Selectors
import Selectors._
val document = Jsoup.parse(???)
val body = select1(document |>> "body") // BFS will find <body> more quickly than DFS
val nav = select(body > "div#page" > "div#nav").headOption
val $ = Selectors.buildIdCache(document)
val footer = $("footer")
- Structural selectors not allowed in string parameters:
select(body > "#page > #nav")
won't do what you expect. String parameters only allow selectors for a single HTML element.
>
: child>>
: traverse descendants using DFS|>>
: traverse descendants using BFS~
: siblings+
: immediate sibling
Find all elements that match the selector.
Find the first element that matches the selector. This macro will generate friendly error message which include the selector.
In contrast to many selectors implementations, ssoup implement selectors in a more direct way. This means:
>
will iterate element's children~
will iterate element's siblings>>
and|>>
will traverse element's all descendants
So you should avoid using more than one >>
or |>>
in a select / select1 call.