Represent XML as a HTML in Flex RichEditableText
I'm developing a word finder of a large text using flex. There I use a RichEditableText to show the whole text and when I find for a word I want to represent all the matching words of that text in a different colour. So I replace all the matching words with html colour changing tags as follows.
var replacedContent:String = txtRichBox.Text.replace(new RegExp(txtSearch.text,"g"), "<font color='#ff0000'>"+txtSearch.text+"</font>");
And then I set it to the RichEditableText as a HTML as follows.
txtRichBox.textFlow = TextConverter.importToFlow(replacedContent, TextConverter.TEXT_FIELD_HTML_FORMAT);
This works supper fine.
Now I have a new requirement. There the original text can be a XML. Then if I set the XML with colour changing html tags to the RichEditableText as a HTML everything crash because it takes XML tags also as HTML tags.
So I tried to replace < and > sings of the XML with < and >.
//Replace < with <
replacedContent:String = txtFileContent.text.replace(new RegExp("<","g"), "<");
//Replace > with >
replacedContent = replacedContent.replace(new RegExp(">","g"), ">");
Then RichEditableText won't render them back to < and > sings. It shows < and > as it is.
Can anyone suggest me a solution for this?
链接地址: http://www.djcxy.com/p/15368.html上一篇: 如何设置Qtextedit背景颜色?