Build Status codecov Maven Central Join the chat at https://gitter.im/nrinaudo/kantan.xpath

kantan.xpath is an XPath expression evaluation library for the Scala programming language.

Getting started

kantan.xpath is currently available for Scala 2.10, 2.11 and 2.12.

The current version is 0.1.9-SNAPSHOT, which can be added to your project with one or more of the following line(s) in your SBT build file:

// Core library, included automatically if any other module is imported.
libraryDependencies += "com.nrinaudo" %% "kantan.xpath" % "0.1.9-SNAPSHOT"

// Java 8 date and time instances.
libraryDependencies += "com.nrinaudo" %% "kantan.xpath-java8" % "0.1.9-SNAPSHOT"

// Provides scalaz type class instances.
libraryDependencies += "com.nrinaudo" %% "kantan.xpath-scalaz" % "0.1.9-SNAPSHOT"

// Provides cats type class instances.
libraryDependencies += "com.nrinaudo" %% "kantan.xpath-cats" % "0.1.9-SNAPSHOT"

// Provides "dirty" HTML parsing through NekoHTML.
libraryDependencies += "com.nrinaudo" %% "kantan.xpath-nekohtml" % "0.1.9-SNAPSHOT"

// Provides joda-time decoders.
libraryDependencies += "com.nrinaudo" %% "kantan.xpath-joda-time" % "0.1.9-SNAPSHOT"

Motivation

Web scrapping is something that I have to do with some regularity, and the standard Scala XML library is not well suited for that task - not as well, at least, as a proper XPath implementation.

The standard Java library, on the other hand, has an acceptably efficient XPath API, but one that is hobbled, from a Scala perspective, by terrible types and safety issues. Everything throws and everything is a node.

kantan.xpath, then, is a thin layer over that Java API that attempts to provide much needed safety, useful types and as little boilerplate as possible.

Tutorials

The following tutorials are available: