0

I want my string resource to be a a section of javascript this contains the character '<' when I add it xml treats it as the start of a tag. How do I include < in my string without it being seen as part of a tag?

Lawtonj94
  • 309
  • 1
  • 5
  • 16

2 Answers2

8
Entity                     Character    Name    Usage
left angle bracket            <          lt     &lt;
right angle bracket           >          gt     &gt;
ampersand                     &          amp    &amp;
single quote or apostrophe    '          apos   &apos;
double quote or speech mark   "          quot   &quot;
W4R10CK
  • 5,502
  • 2
  • 19
  • 30
5

You'll need to use an entity for the character. In this case &lt; should be substituted for <.

Daniel Waghorn
  • 2,997
  • 2
  • 20
  • 33
  • I knew it would be something like that. Do you have a list of these I could not find them? – Lawtonj94 Sep 14 '16 at 10:42
  • [This answer](http://stackoverflow.com/questions/13056481/escaping-special-characters-like-in-android-xml) references a complete list of characters which need to be escaped with their entities. – Daniel Waghorn Sep 14 '16 at 10:46
  • @Lawtonj94 Check [this](http://www.degraeve.com/reference/specialcharacters.php). It may helpful. – Raghavendra Sep 14 '16 at 10:50