Special characters in the XML response received from the server

In my Scala code, I get a response from the server using the getInputStream method of the HttpUrlConnection class. The answer is XML data. However, the data does contain HTML objects such as & and ' .

Is there a way to replace these characters with my text equivalent so that I can parse XML correctly?

+6
source share
1 answer

You must encode these objects in xml so that they do not interfere with its syntax. Objects &lt; (<) and &gt; (>) make this more obvious. It would be impossible to parse XML whose contents were littered with <and> characters.

Scala's scala.xml package should provide you with the tools you need to parse your xml. Here are some tips from the author of the library.

+3
source

Source: https://habr.com/ru/post/888222/


All Articles