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.
XML
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 CDATA. Below is an example:
<?xml version="1.0" encoding="iso-8859-1"?> <section> <content><![CDATA[Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br><br>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<br><br><font color="#0099FF">Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</font><br><br>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<br><br>List:<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>]]></content> </section>
By encapsulating the text string inside <![CDATA[]]>, this tells Flash to just treat everything inside the CDATA tag as a pure string, and to ignore any HTML tags that it may contain.
Actionscript
Once this string is read into Flash and assigned to a variable (in my example, the variable name is htmlContent), you will then most likely need to display this text. Create a text field on the stage, and select the “Render text as HTML” button in the text field properties. Give the text field an instance name (e.g. “contents_txt”). Then assign the variable “htmlContent” to the “htmlText” property of the text field.
contentXML.onLoad = function() {
...
contents_txt.htmlText = htmlContent;
}
By assigning the string to “htmlText“, this tells Flash to then render the text inside the text field using the HTML tags. Simple!
I’ve created example files for you to download and look at. AS2 version is here and AS3 version is here.
Hope this helps some of you out there to get those HTML tags rendering in Flash.


RSS
I will stick a link to this page on my website. I am sure my readers will find this post very useful.
Really great idea. I’m very glad to read this post. Thank you for giving us nice entries.
Excellent stuff.
Can I link as much as this, through my own page? I’m planning to gather as much sources of info as i am able.
Should I buy steel golf clubs or graphite ?
Very informative post. Thanks for taking the time to share your view with us.
I find myself coming to your blog more and more often to the point where my visits are almost daily now!
Very informative post. Thanks for taking the time to share your view with us.
Thanks for the information provided! I was researching for this data for a long time, but I was not able to find a reliable source.
I enjoyed reading it. I need to see more on this topic.. Thank you for sharing this amazing info.. Anyway, I’m gonna subscribe to your feed and I hope you post again soon.
Terrific work! This is the type of information that should be shared around the web. Shame on the search engines for not positioning this post higher!
Great post. YOu make it seem so easy to share your experiences. I wish I could do as well in sharing on my blog. I just got it started and sometimes feel stuck on what to share or if it is the right thing to share. what to do?
Sorry to be off topic, but I like your posts and I wanted some feedback for my blog. I have a hard time writing, but I do want to share my experiences. Am I stuck between a rock and a hard place? Or should I just do it?
Should I buy steel golf clubs or graphite ?
Thanks For This Post, was added to my bookmarks.
Hey – nice blog, just looking around some blogs, seems a pretty nice platform you are using. I’m currently using Wordpress for a few of my sites but looking to change one of them over to a platform similar to yours as a trial run. Anything in particular you would recommend about it?
Nice site, I just dugg this keep up the good work!. . . . . .
Hi I found your site by mistake when i was searching yahoo for this acne issue, I must say your site is really helpful I also love the design, its amazing!. I don’t have the time at the moment to fully read your site but I have bookmarked it and also add your RSS feeds. I will be back in a day or two. thanks for a great site.
I completely agree with the above comment, the internet is with a doubt growing into the most important medium of communication across the globe and its due to sites like this that ideas are spreading so quickly.
Thanks For This Post, was added to my bookmarks.
First of all, this is a good site you have here. I stumbled upon your web site while doing a search on google. Fantastic blog post, I will probably bookmark it for future reading.
I’ve been visiting your blog for a while now and I always find a gem in your new posts. Thanks for sharing.
Awesome Blog. I add this Post to my bookmarks.
I am not really sure if best practices have emerged around things like that, but I am sure that your great job is clearly identified. I was wondering if you offer any subscription to your RSS feeds as I would be very interested.
I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work.
Which golf clubs will be the best for beginner ?
I am not really sure if best practices have emerged around things like that, but I am sure that your great job is clearly identified. I was wondering if you offer any subscription to your RSS feeds as I would be very interested.
Excellent writing about Blog health, it is actually useful for me. keep writing and happy blogging.
Thank You For This Blog, was added to my bookmarks.
Hey – great blog, just looking around some blogs, seems a really nice platform you are using. I’m currently using Wordpress for a few of my blogs but looking to change one of them over to a platform similar to yours as a trial run. Anything in particular you would recommend about it?
Nice intriguing article. It provides informative insights to the blog readers like me.
Supra Vega Black, Supra Vega Black
Supra Vega Foresst, Supra Vega Foresst
Supra Vege blue, Supra Vege blue
Nice post! I want to subscribe this blog, but I don’t know how to do, can anybody give me a hand?
This is a good step to save paper. And will save the rain forests in Indonesia. Moreover, this will reduce the burden on the back of elementary school students. Of course this will make the traditional printing companies and governments in the third world into a panic because of their unpreparedness of information technology. . .
I must say, I thought this was a pretty interesting read when it comes to this topic. Liked the material. . . . .
Very nice and helpful information has been given in this article. I like the way you explain the things. Keep posting. Thanks. . .
You certainly deserve a round of applause for your post and more specifically, your blog in general. Very high quality material.
You certainly have some agreeable opinions and views. Your blog provides a fresh look at the subject.
what a incredible publish, wow.
What a good blog you have here. Please update it more often. This topics is my interest. Thank you. . .
Because even though I still see Bailey Button Ugg Boots in the city sometimes, they’re usually beat-up, stained, and relegated to Whole Foods shopping in the snow.Is this a regional thing?Because we’re doing a highly scientific study …
I’m serious in obtaining oneway link on this internet site. If you please email us with the worth. Thanks.
Good informative post. I will visit your site often to keep updated.
Thanks I really needed this.
Guys, Great article and very very interesting blog. That’s one thing I’m really looking forward. Looking forward to reading more from you next week.
How are you ?! Could possibly I move your text in Pdf format? I really need it in my training course.
I must say, I thought this was a pretty interesting read when it comes to this topic. Liked the material. . . . .
Adding to my bookmarks thanks. Needed more pictures though.
Hands down, Apple’s app store wins by a mile. It’s a huge selection of all sorts of apps vs a rather sad selection of a handful for Zune. Microsoft has plans, especially in the realm of games, but I’m not sure I’d want to bet on the future if this aspect is important to you. The iPod is a much better choice in that case.