- Home /
Displaying xml content with rich text
I have an xml
file that contains some survey questions, for example the following line that represents the survey title:
<title>Please describe how you feel now.</title>
The following simple code displays the above in my editor:
GUILayout.BeginHorizontal( displayStyle1 );
displayStyle1.fontSize = 20;
GUILayout.Label( Title, displayStyle1 );
GUILayout.EndHorizontal();
I decided to make the word NOW show in bold or perhaps underlined, so I inserted the following line in my code:
displayStyle1.richText = true;
and then changed the xml
content to:
<title>Please describe how you feel <b>now</b>.</title>
But it is not making any difference. What am I missing or doing wrong?
Thank you
Answer by Bunny83 · May 08, 2015 at 11:49 PM
It would help to see how you actually read in the XML. Keep in mind that <b> </b>
are valid xml tags and if you use an XML parser it will parse those as tags. If you want your bold tags to be part of the actual text you should wrap your text in a CDATA section or use innerHTML (if your used parser / framework support it)
So by using this:
<title><![CDATA[Please describe how you feel <b>now</b>.]]></title>
all text between the `` should be treated as text when you parse the xml file.
Your answer
![](https://koobas.hobune.stream/wayback/20220613194645im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A node in a childnode? 1 Answer
How To Switch A XmlNodeList To A String 1 Answer
Declaring XML Namespace at Runtime 1 Answer
Saving new children/subchildren in XML 0 Answers
Load file on Android 1 Answer