How to put ampersand into string

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How to put ampersand into string

Postby konic » Wed Sep 30, 2009 1:51 pm

The question is simple but yet I don't know the answer.
The following line returns error:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <string name="prices">PRICES & TAXES</string>
  2.  
Parsed in 0.000 seconds, using GeSHi 1.0.8.4

because of the ampersand sign inside the string.
However the following line in code
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. someBtn.setText("PRICES & TAXES");
  2.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

compiles just fine.
So, is there any way to insert ampersand into string in XML file?
konic
Developer
Developer
 
Posts: 32
Joined: Mon Aug 24, 2009 3:16 pm

Top

Postby azraeal » Wed Sep 30, 2009 6:39 pm

It's xml, so
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. &
Parsed in 0.000 seconds, using GeSHi 1.0.8.4
is probably escaped as
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. &amp;
Parsed in 0.000 seconds, using GeSHi 1.0.8.4
azraeal
Experienced Developer
Experienced Developer
 
Posts: 71
Joined: Fri Sep 04, 2009 6:34 pm
Location: California

Postby konic » Wed Sep 30, 2009 9:09 pm

azraeal wrote:It's xml, so ...
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. &amp;
Parsed in 0.000 seconds, using GeSHi 1.0.8.4

Damn, I missed that ";" !
Thanks.
konic
Developer
Developer
 
Posts: 32
Joined: Mon Aug 24, 2009 3:16 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 3 guests