Reputation: 198388
val name = "mike"
val xml = <name>{name}</name>
xml will be <name>mike</name>
But what if I want the xml be <name>{name}</name>
, not convert the {name}
?
Upvotes: 9
Views: 1069
Reputation: 2918
To complement other answers, you can also provide a Text
node inside your XML literal:
import scala.xml.Text
<xml> {
Text("{foo}")
} </xml>
will produce,
<xml> {foo} </xml>
Upvotes: 6
Reputation: 35689
Sounds like you need to use the xml entities for { }
and not { }
themselves.
For example:
val name = "mike"
val xml = <name>{name}</name>
Upvotes: 1
Reputation: 20134
you can escape the curly braces by doubling them
val xml = <name>{{name}}</name>
will give you
<name>{name}</name>
Upvotes: 17