0

Hello currently given the following string:

<strong>Headline</strong>Line 1<br/>Line 2<br/>Line 3<br/>Line 4<br/>Line 5<br/>

How could I extract the text so that I get:

Headline
Line 1
Line 2
...

Currently the biggest problem for me is that Scala XML .text will remove the node's and won't make a \n at , however that is odd. Is there a way to get a \n for each ?

Christian Schmitt
  • 837
  • 16
  • 47

1 Answers1

1

Assume you expect smth like following:

scala> val x = <x><strong>Headline</strong>Line 1<br/>Line 2<br/>Line 3<br/>Line 4<br/>Line 5<br/></x>
scala> println(x.child.map { v => v.text}.mkString("\n"))
Headline
Line 1

Line 2

Line 3

Line 4

Line 5
vvg
  • 6,325
  • 19
  • 36
  • 1
    That's not quite correct however it's the correct solution. I just forgotten about `child`. The only thing what's wrong on yours is the newline after each line, however that's easy to tackle, thanks. I'm totally dumb today. – Christian Schmitt Dec 14 '15 at 16:12