1

If I use the loadString method to load HTML containing a <br/> tag, Scala's XML lib wants to convert that to the longer, and seemingly less standard <br></br> (which unfortunately even seems to render differently than the plain-old <br/> in some browsers).

I.e., the following...

val xml = scala.xml.XML.loadString("<body>Hi<br/>there.</body>")
xml.toString()

...yields...

<body>Hi<br></br>there.</body>

Is there a way to force Scala's XML lib to render the tag as a "singleton"?

4

1 回答 1

3

不是这样!

scala> val xml = scala.xml.XML.loadString("<body>Hi<br/>there.</body>")
xml: scala.xml.Elem = <body>Hi<br/>there.</body>

scala> xml.toString()
res0: String = <body>Hi<br/>there.</body>

当然,您使用的不是 Scala 2.10.0,所以您可以看到您所看到的。

于 2013-02-19T01:27:50.453 回答