Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I using '&' in android resource strings.xml file in android studio? [duplicate]

Tags:

xml

As shown in the title,I define a String using '&' in strings.xml file,but the android studio show a error? strings.xml

<string name="url">
    url?locale=zh&articleNo=
</string>

Problems can be redefined:

We can't using special characters which have special meaning in XML.

The question is the XML syntax problems.


1 Answers

Use &amp; instead of just &

UPD:
Answer to "Why can't you use &" is: it is by design: http://www.w3.org/TR/xml/#charsets

The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they MUST be escaped using either numeric character references or the strings " & " and " < " respectively. The right angle bracket (>) may be represented using the string " > ", and MUST, for compatibility, be escaped using either " > " or a character reference when it appears in the string " ]]> " in content, when that string is not marking the end of a CDATA section.

like image 60
krossovochkin Avatar answered Oct 22 '25 06:10

krossovochkin