Scala XML literal generation with for-yield

smilebeccasyou

New Member
Is there any way to generate XML using the literal syntax as such:\[code\]<a>{ for (i <- Range(1, 3)) yield { <b>{i}</b> }}</a>\[/code\]that will return\[code\]<a><b>1</b><b>2</b></a>\[/code\]i.e. I want to use just a single compound statement which will somehow return the complete XML literal.The only way I know is to do it in two steps: in the first step the for-yield statement will return IndexedSeq or something similiar which then in the second step I have to convert it to scala.xml.Elem. That's OK, but I get the feeling that you can be more concise - nearly as concise as what I proposed in my code above.Thanks.
 
Back
Top