String Resource new line /n not possible?

Andi Jay picture Andi Jay · Mar 28, 2011 · Viewed 164.8k times · Source

It doesn't seem like it's possible to add a new line /n to an XML resource string. Is there another way of doing this?

Answer

james picture james · Mar 28, 2011

use a blackslash not a forwardslash. \n

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="title">Hello\nWorld!</string>
</resources>

Also, if you plan on using the string as HTML, you can use &lt;br /&gt; for a line break(<br />)

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="title">Hello&lt;br /&gt;World!</string>
</resources>