writing some characters like '<' in an xml file writing some characters like '<' in an xml file xml xml

writing some characters like '<' in an xml file


Another way to insert special character follow Moss guide: How can I write character & in android strings.xml by used Unicode definition:

Example:

<string name="item_unknown">\u003c Item Unknown \u003e</string>

which present in string :

< Item Unknown >


I stumbled upon this question, as I use HTML markup in my strings.

If you refer to the Android String Resources documentation,in the section:"Styling with HTML markup"you will see that in strings.xml, you need to use < for an opening bracket, but you can safely use backslash and a closing bracket. For example:

<b>Text</b>

can be written as:

<b>Text</b>

in your strings.xml.

If using this HTML string in your code, you can use:

Html.fromHtml( getResources().getString(R.string.yourHTMLString ) 

and the output will be your bold string!