开发者

Required help required in rendering HTML text containing advanced HTML tags like <strong>, <em>, <span> and advanced HTML entities in Flex

开发者 https://www.devze.com 2023-03-25 15:46 出处:网络
I am designing a web application in Flex 4 and currently facing an issue rendering advanced HTML tags and entities in Flex 4.

I am designing a web application in Flex 4 and currently facing an issue rendering advanced HTML tags and entities in Flex 4.

All I want to do is basically render an HTML text coming to me something like the one given below:-

<p>&lt; hkhj &nbsp;&gt;&nbsp;&pound; &nbsp;&le; &nbsp;&ge;&nbsp;
&iquest; &nbsp;&Eacute; &nbsp;&Ograve; Netscape 4.7 <strong>dooesn</strong>'t 
<span style="text-decoration: underline;">respond</span> for <em>following</em> 
things.</p>

I am using the RichText Component of Flex Spark to render this html in the following manner.

<fx:Script>
    <![CDATA[
        var htmlString:String = "<p>&lt; hkhj &nbsp;&gt;&nbsp;&pound; &nbsp; &le; &nbsp;&ge;&nbsp;
&iquest; &nbsp;&Eacute; &nbsp;&Ograve; Netscape 4.7 <strong>dooesn</strong>'t 
<span style="text-decoration: underline;">respond</span> for <em>following</em> 
things.</p>"
    ]]>
</fx:Script>

<s:RichText width="100%" 
   textFlow="{TextConverter.importToFlow(htmlString,TextConverter.TEXT_FIELD_HTML_FORMAT)}" />

What I observe is in my flex application is that the following HTML tags have no effect in on the HTML text:-

<strong> <开发者_如何学Python;span> <em> 

Also, following HTML entites are displayed as it is (not converted to their respective symbols/characters):-

&pound; &Eacute; &Ograve; &iquest; &le; &ge;

Is this a limitation in Flex?

Any pointers to render this HTML text with all the tags and entities mentioned shall be appreciated.

Thanks,

Mangirish


Flex supports only a subset of HTML tags within htmlText. See the documentation here:

http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7d52.html

As for the entities, I could not find a list of what was supported and what was not.

As for your problem, it would be easiest to convert those tags to their equivalent (for example, you could change all strong tags to b since b is supported within Flex. You could do some regular expression work to convert them.


Following links might be useful:

Setting text in a spark richtext control

OR

Displaying HTML formatted text in Spark RichText control


I figured out a way to render html entities in Flex.

The solution is the HTML code should contain HTML "numeric" entity codes and not "named"

"To use the special characters left angle bracket (<), right angle bracket (>), and ampersand (&), insert the XML character entity equivalents of <,>, and &, respectively. You can also use " and ' for double-quotation marks (") and single-quotation marks ('), and you can use numeric character references, such as ¥ for the Yen mark (¥). Do not use any other named character entities; Flex treats them as literal text."

For more on this here is the link:-

http://help.adobe.com/en_US/Flex/4.0/UsingSDK/WS2db454920e96a9e51e63e3d11c0bf69084-7d53.html

0

精彩评论

暂无评论...
验证码 换一张
取 消