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 ?

4

1 回答 1

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
于 2015-12-14T15:48:39.253 回答