PeakGen
PeakGen

Reputation: 23035

How to use escape characters in XML

How can I use escape characters in XML?

The situation is, I am a new android developer, and I need a string which need to be printed in 2 lines (other wise no space). This string is in string.xml file. I need to use /n line break character to break the string, but I don't know how to do it in XML file. Please help.

Upvotes: 0

Views: 326

Answers (4)

Alex
Alex

Reputation: 379

See reference http://developer.android.com/guide/topics/resources/string-resource.html#String

line break symbol is \n

/n - is wrong. and you can write it in xml like it is.

Example:

    <string name="multiline_text">line 1.\nline2.</string>

Upvotes: 1

Dabbler
Dabbler

Reputation: 9873

You can use the character entity &#xA; to indicate a linefeed.

Upvotes: 1

sdabet
sdabet

Reputation: 18670

You can use double quotes:

<string name="mystring">"One line\nAnother line"</string>

Upvotes: 1

alan
alan

Reputation: 6953

I'm not familiar with Android development but have you checked out CDATA? Refer to this link.

Basically, you wrap your string value like so:

<![CDATA[string value]]>

Upvotes: 1

Related Questions