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>
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>
Sounds like you need to use the xml entities for { }
and not { }
themselves.
For example:
val name = "mike"
val xml = <name>{name}</name>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With