1

My strings.xml looks like this:

<string name = "app_name>A & B</string>

Eclipse is throwing an error: "The entity name must immediately follow the & in the entity reference". What can be the reason?

webgenius
  • 856
  • 3
  • 13
  • 30

4 Answers4

7

Use

<string name = "app_name>A &amp; B</string>

Doc reference

Adam Radomski
  • 2,515
  • 2
  • 17
  • 28
2

For special character I normally use the Unicode definition, so for the '&' use \u0026

Or Encoding it to &amp;

i.e. Use

<string name = "app_name>A &amp; B</string>

For more info see this link

Giru Bhai
  • 14,370
  • 5
  • 46
  • 74
1

& is a special character in xml, it indicates start of an entity.So use "&" instead of &(add "amp;" to &)

NIPHIN
  • 1,071
  • 1
  • 8
  • 16
0

You must encode the '&' symbol with &amp; while you are using it inside XML files.

This should work fine

<string name = "app_name>A &amp; B</string>
gnuanu
  • 2,252
  • 3
  • 29
  • 42