32 chars · 1 line
Waiting for input
32 chars · 1 line
Waiting for input
XML character escaping
The sample uses < as ordinary comparison text inside message. XML reserves that character to start markup, so literal data must encode it as < or place appropriate text in a CDATA section when that better fits the source. This tool is free to use. No account or payment is required.
Last updated
When a parser sees < in ordinary character data it expects valid markup to follow. A comparison expression or prose fragment therefore needs escaping if the symbol is part of the text value.
CDATA sections can hold many characters that would otherwise look like markup, but they have their own closing delimiter and should be used intentionally rather than as a blanket replacement for ordinary escaping.
Encode the comparison symbol without changing the message value.
<message>value < limit</message><message>value < limit</message>Common questions
Use < when the less-than character is data rather than markup.
Not in ordinary text in the same way < does, though escaping it as > can still be useful in some contexts.
Yes. CDATA is designed for text that would otherwise contain markup-like characters, subject to its own ]]> delimiter rule.
Debugging a specific XML issue? Browse XML troubleshooting.