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}
?
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}
?
you can escape the curly braces by doubling them
val xml = <name>{{name}}</name>
will give you
<name>{name}</name>
Sounds like you need to use the xml entities for { }
and not { }
themselves.
For example:
val name = "mike"
val xml = <name>{name}</name>
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>