Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
We’ll start with the basics: how to turn a string full of XML into a data structure we can work with:
// code-examples/XML/reading/from-string-script.scala
import scala.xml._
val someXMLInAString = """
<sammich>
<bread>wheat</bread>
<meat>salami</meat>
<condiments>
<condiment expired="true">mayo</condiment>
<condiment expired="false">mustard</condiment>
</condiments>
</sammich>
"""
val someXML = XML.loadString(someXMLInAString)
assert(someXML.isInstanceOf[scala.xml.Elem])