How i can set attribute value like value for elements in scala.xml
This not work :(
def getXml(fooValue: String, barValue: String): Node =
val fooBar = <foo bar="{barValue}">
{ fooValue }
</foo>
How i can set attribute value like value for elements in scala.xml
This not work :(
def getXml(fooValue: String, barValue: String): Node =
val fooBar = <foo bar="{barValue}">
{ fooValue }
</foo>
This way it would work:
def createXMLElement(value: String, attributeValue: String) : Node =
<foo attribute={attributeValue}>{value}</foo>
scala> createXMLElement("Hello World", "boring")
res2: scala.xml.Node = <foo attribute="boring">Hello World</foo>
In the example given you assign
the result to a val
and expect the return type Node
. The returntype of the assignement is Unit
though.