user256239
user256239

Reputation: 18027

How to decode encoded special XML characters in a string?

I was given a string like

example.com/test?region=us&lang=en&jurisdiction=us

How can I write the java code to decode the encoded characters like

& 

in the string. Is there any existing class/method to decode them?

Thanks.

Upvotes: 18

Views: 30515

Answers (3)

BalusC
BalusC

Reputation: 1109462

To unescape HTML/XML entities, use Apache Commons Text StringEscapeUtils or homegrow one.

Upvotes: 26

Roger F. Gay
Roger F. Gay

Reputation: 1971

You can also include special characters in XPL. XPL has exactly the same structure as XML, but allows special characters. There is an XML parser with source code available for transformations at http://hll.nu

Upvotes: 0

Jaime Hablutzel
Jaime Hablutzel

Reputation: 6342

StringEscapeUtils seems to escape everything

Upvotes: 2

Related Questions