Scala support for Inline XML

Scala supports defining inline XML, a bit like PHP does. It features string interpolation but using just braces – no dollar signs.


object Movies extends App {
  val title="Goodfellas"
  val genre="Gangster"
  val movie = <movie genre={genre}><title>{title}</title></movie>
  println("movie = " + movie)


movie = <movie genre="Gangster"><title>Goodfellas</title></movie>

The resulting var is a scala.xml.Elem


One thought on “Scala support for Inline XML

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s