<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Weblenium &#187; tags</title>
	<atom:link href="http://www.weblenium.com/tag/tags/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.weblenium.com</link>
	<description></description>
	<lastBuildDate>Mon, 29 Nov 2010 12:31:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Reading HTML tags from XML into Flash</title>
		<link>http://www.weblenium.com/2009/05/reading-html-tags-from-xml-into-flash/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://www.weblenium.com/2009/05/reading-html-tags-from-xml-into-flash/#comments</comments>
		<pubDate>Thu, 07 May 2009 18:02:29 +0000</pubDate>
		<dc:creator>phorner</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[tags]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.weblenium.com/?p=363</guid>
		<description><![CDATA[One problem that many people experience when working with XML and Flash is getting HTML tags inside the XML to be read in and rendered in Flash. Reading XML that contains HTML tags is a very common thing to do these days, as Flash gets used more and more to create applications since the release [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.weblenium.com/wp-content/uploads/2009/05/flashplayer_10_small.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="size-full wp-image-388 alignleft" title="Flash" src="http://www.weblenium.com/wp-content/uploads/2009/05/flashplayer_10_small.jpg" alt="Flash" width="84" height="83" /></a>One problem that many people experience when working with XML and Flash is getting HTML tags inside the XML to be read in and rendered in Flash. Reading XML that contains HTML tags is a very common thing to do these days, as Flash gets used more and more to create applications since the release of Adobe AIR. So here is a tutorial showing you the basics of how to do it.</p>
<p><span style="text-decoration: underline;"><strong>XML</strong></span></p>
<p>The trick to getting the XML parser in Flash to ignore the HTML tags is to encapsulate the text string containing the HTML tags using <strong>CDATA</strong>. Below is an example:</p>
<pre class="brush: xml; ">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot;?&gt;
&lt;section&gt;
&lt;content&gt;&lt;![CDATA[Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.&lt;br&gt;&lt;br&gt;Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;br&gt;&lt;br&gt;&lt;font color=&quot;#0099FF&quot;&gt;Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.&lt;/font&gt;&lt;br&gt;&lt;br&gt;Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;br&gt;&lt;br&gt;List:&lt;ul&gt;&lt;li&gt;Item 1&lt;/li&gt;&lt;li&gt;Item 2&lt;/li&gt;&lt;li&gt;Item 3&lt;/li&gt;&lt;/ul&gt;]]&gt;&lt;/content&gt;
&lt;/section&gt;
</pre>
<p>By encapsulating the text string inside <strong>&lt;![CDATA[]]&gt;</strong>, this tells Flash to just treat everything inside the <strong>CDATA </strong>tag as a pure string, and to ignore any HTML tags that it may contain.</p>
<p><span style="text-decoration: underline;"><strong>Actionscript</strong></span></p>
<p>Once this string is read into Flash and assigned to a variable (in my example, the variable name is <strong>htmlContent</strong>), you will then most likely need to display this text. Create a text field on the stage, and select the &#8220;<strong>Render text as HTML</strong>&#8221; button in the text field properties. Give the text field an instance name (e.g. &#8220;contents_txt&#8221;). Then assign the variable &#8220;<strong>htmlContent</strong>&#8221; to the &#8220;<strong>htmlText</strong>&#8221; property of the text field.</p>
<pre class="brush: js; ">
contentXML.onLoad = function() {
...
contents_txt.htmlText = htmlContent;
}
</pre>
<p>By assigning the string to &#8220;<strong>htmlText</strong>&#8220;, this tells Flash to then render the text inside the text field using the HTML tags. Simple!</p>
<p>I&#8217;ve created example files for you to download and look at. AS2 version is <a href="http://www.weblenium.com/download/Flash-XML-HTML_AS2.zip#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">here</a> and AS3 version is <a href="http://www.weblenium.com/download/Flash-XML-HTML_AS3.zip#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">here</a>.</p>
<p>Hope this helps some of you out there to get those HTML tags rendering in Flash.</p>
<img src="http://www.weblenium.com/?ak_action=api_record_view&id=363&type=feed" alt="" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.weblenium.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.weblenium.com/2009/05/reading-html-tags-from-xml-into-flash/feed/</wfw:commentRss>
		<slash:comments>2123</slash:comments>
		</item>
	</channel>
</rss>

