Amorgos Amorgos - 1 year ago 79
Android Question

How to put a “-” in string.xml file, but without escaping

I have a configuration.xml file which I hold all the (yep, you guessed it!).. configuration strings and values and stuff.

One of those values is a string which is an oauth client id, and it has a hyphen..

<string name="server_clientid"></string>

Now I get the warning message..

Replace "-" with an "en dash" character (–, &#8211;) ?

Ok fair enough, but if I escape with this then the client id is not valid when I fetch it within the app. I can't use & #8211; basically. How do I get around this?

Answer Source

You wrap your values in

<![CDATA[ ]]> 

which stops the parser from parsing the contents. E.g.

<string name="server_clientid"><![CDATA[ ]]></string>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download