How can I escape "&" in XML? [duplicate]

I write

 <string name="magazine">Newspaper & Magazines</string> 

in file strings.xml.

But the compiler says:

The entity name must immediately follow the '&' in the entity reference. strings.xml /OOReaderWidget/res/values line 9 Android XML Format Problem

How can I show a "&" in strings.xml?

1

3 Answers

Use &amp; in place of &.

Change it to:

<string name="magazine">Newspaper &amp; Magazines</string> 
1

& → &amp;

< → &lt;

> → &gt;

You can use &amp; in place of &

You Might Also Like