How can I escape "&" in XML?

Xml

Xml Problem Overview


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?

Xml Solutions


Solution 1 - Xml

Use &amp; in place of &.

Change it to:

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

Solution 2 - Xml

& → &amp;

< → &lt;

> → &gt;

Solution 3 - Xml

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionherbertDView Question on Stackoverflow
Solution 1 - XmlRam kiran PachigollaView Answer on Stackoverflow
Solution 2 - XmlxshoppyxView Answer on Stackoverflow
Solution 3 - XmlKurtView Answer on Stackoverflow