Can't import scala.xml._

Given the following line of code in a Scala worksheet:

import scala.xml._

this error is generated:

Error: object xml is not a member of package scala

A similar line of code works:

Seems basic, but I've been searching for over an hour with no solution!  Have tried or found:

settings at:  Preferences->General->Auto Import
help page at

Using IntelliJ IDEA 15.1, scala-sdk-2.11.7

Thanks in advance for any help!


Found an answer. says: "As of Scala 2.11, this library is a separate jar that can be omitted from Scala projects that do not use XML."
Thus scala-xml needs to be downloaded & included as a dependency:
cmd-; Project Settings -> Modules -> Dependencies
click + in bottom-left -> 2 Library -> From Maven
In the search box of the popup, type the library name "scala-xml" and click the search icon.  A long list of possibilities shows up, and I chose the most recent version corresponding to my version of Scala, 2.11.


Thanks, Mark.  This was a big help!


You can also use SBT for this.  See to get started with SBT.  Once that is setup, all you need to do is update your build.sbt file with no need to update the project settings in Idea.  Fully functional build.sbt file shown below.

name := "AppName"

version := "1.0"

scalaVersion := "2.11.8"

libraryDependencies ++= Seq("org.scala-lang.modules" % "scala-xml_2.11" % "1.0.6")


in my case clearing the .bsp and .bloop project-subfolders was needed to get it running, sbt clean was not enough


Please sign in to leave a comment.