In my Scala code, I am fetching a response from a server using the getInputStream
method of HttpUrlConnection
class. The response is XML data. However the data contains HTML entities like &
and '
.
Is there a way I can replac开发者_运维知识库e these characters with their text equivalent so that I can parse the XML properly?
It's necessary to encode those entities in xml so they don't interfere with its syntax. The <
(<) and >
(>) entities make this more obvious. It would be impossible to parse XML whose content was littered with < and > symbols.
Scala's scala.xml package should give you the tools you need to parse your xml. Here's some guidance from the library's author.
精彩评论