About the XML Unescape
Text pulled out of an XML document by a regular expression or a log line still carries its entities: & where an ampersand should be, < for a less-than sign. This tool reverses the escaping. It handles the five predefined entities and both decimal (©) and hexadecimal (—) character references.
The rule is deliberately narrow. XML predefines exactly amp, lt, gt, quot and apos, and any other name would have to be declared in a document type definition, so a name this tool does not recognise is left exactly as it stands rather than guessed at. Numeric references are resolved by code point, in decimal after &# and in hexadecimal after &#x, which reach the same character either way.
Two things catch people out. Doubly escaped text, where &lt; appears, needs two passes: run the tool, then run it again on the output. And HTML entities such as , é or © are not XML entities at all, so they come through untouched; HTML Unescape knows the full list of roughly two thousand names.
The usual case is a headline or description scraped from an RSS or Atom feed, where the publisher escaped the text and your reader is showing the entities raw. Since nothing is parsed, it works on fragments and on markup that is not well-formed. To escape text on the way back in, use XML Escape; to turn a whole document into structured data instead, XML to JSON decodes entities as it converts.
How to use
- Paste the escaped text.
- Read or copy the decoded text.
- Run it again if the text was escaped twice.
Common questions
- Which entities are supported?
- amp, lt, gt, quot and apos, plus any numeric reference in decimal or hex form.
- What about or ©?
- Those are HTML entities, not XML. The HTML Unescape tool decodes them.
- Does it parse the XML?
- No, it only replaces entities in the text, so it works on fragments and on text that is not well-formed.