Peter Nelson
Peter Nelson

Reputation: 5967

Escaping Angle Brackets in XML in Eclipse / Android

If I want to to label some buttons with ">" and "<" symbols, what's the correct way to escape them out in the XML file? The presence of either ">" or "&" (as in "&gt") produces "invalid token" errors.

Thanks in advance.

Upvotes: 37

Views: 31810

Answers (1)

Brian Showalter
Brian Showalter

Reputation: 4349

Either specify those characters like this:

< = &lt;
> = &gt;

Or use a CDATA section and put those characters inside:

<![CDATA[<]]>
<![CDATA[>]]>

Upvotes: 83

Related Questions