Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

escaping special characters like & in android xml

Tags:

android

<string name="app_name">something & something</string>  

gives an error. How can i escape this?

Is this correct

<string name="app_name">something &amp; something</string> 

or is there a better way?

like image 454
mbrc Avatar asked Oct 24 '12 19:10

mbrc


People also ask

How do you type escape characters?

Character combinations consisting of a backslash (\) followed by a letter or by a combination of digits are called "escape sequences." To represent a newline character, single quotation mark, or certain other characters in a character constant, you must use escape sequences.

What are escape characters in SQL?

In ANSI SQL, the backslash character (\) is the escape character. To search for data that begins with the string \abc , the WHERE clause must use an escape character as follows: ... where col1 = '\\abc';


2 Answers

Try reading this page: http://www.xmlnews.org/docs/xml-basics.html it looks like it contains the answer you are looking for.

In summary, here is the list of escaped characters and the escape code

Character  Predeclared Entity &          &amp; <          &lt; >          &gt; "          &quot; '          &apos; 

Referenced from the link.

like image 175
JoxTraex Avatar answered Sep 21 '22 00:09

JoxTraex


For me &quot ; didin't work so I used \"" and this character was escaped.

like image 41
user1252459 Avatar answered Sep 23 '22 00:09

user1252459