Question

CDATA in xml to flash

Asked by: chefkeifer

I am having and issue of a picture showing up in the body of a attribute ( I think that is what you call it. I need for the user to be able to have and article what has a picture in the middle of it. i thought if you just pt the CDATA function in the middle or at the beginning that image would show up here is the code i have in xml format. the only thing that shows up is the actual code and not the image.

<information>
    	<articleName>Jan.25th Meeting Minutes</articleName>
    	<article><![CDATA[<img src="imagesTCR/carolinaMap.gif" height="250" width="250" alt="bikeGiveaway"/>      		
		<font size="14">This sizzling bikes shouting You know you wanna win me, take me, love me, ride MEEEE!!!! </font>
 
The picture was taken at Harley-Davidson of Charlotte where they are promoting their upcoming August 29th Red White and Brew, an event which is recently adopted by the dealership on Independence Boulevard.   Its a fourth annual event generated by Budweiser and first time at this venue.  Along with plenty to get folks there including a bike show and live music, venders and food, as well as the bike raffle of course; the events getting really revved up with something new and spicy: the finals of the local Karney Law Firm Daisy Dukes contest.  Plus, theres an after-party for the big Red White and Brew-day thats being held at McKoys Smokehouse on Old Pineville Road, the same location that will hold the Daisy Dukes Semi-Finals on Saturday, August 15th with live music, give-aways, and the usual out-of-this-world McKoys food and goodtimes atmosphere.    Registrations for the bike are taking place NOW.  Registrations for the Daisy Dukes contest are being taken by Jon Pendleton of Satisfaction Marketing.   For more information about all the events, check out www.h-dofcharlotte.com]]>
 
    	</article>
  </information>

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-08-23 at 10:24:57ID24674841
Tags

CDATA

,

xml

,

flash

,

as3

,

dreamweaver

Topics

Extensible Markup Language (XML)

,

ActionScript

,

Adobe Flash

Participating Experts
2
Points
500
Comments
31

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. XML Transformation and CDATA Sections
    I have an XML element which contains HTML text which is not well-formed. So I contained the HTML in a CDATA section. . I am running a transformation using XSL to convert my document into HTML to be viewed in a browser. The parsing and the transformation work fine, except that...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: abelPosted on 2009-08-23 at 10:28:01ID: 25163445

You don't need CDATA at all, because CDATA actually makes your data literal, which is why you see the whole link as text (it is escaped).

Instead, remove the CDATA. The img tag is nothing more then valid XML, which is find to be placed there. Just make sure that you use something like the XSLT xsl:copy to copy the whole structure.

 

by: chefkeiferPosted on 2009-08-23 at 10:42:11ID: 25163489

XSLT xsl:copy to copy the whole structure.

I am not familiar with that at all...can you give me an example?

will the image show up in a textArea component or does it have to be a dynamic text box?

 

by: abelPosted on 2009-08-23 at 11:19:19ID: 25163604

I'm afraid I can only help with that if you show how you currently load that very same CDATA section. It depends a lot on language and techniques used. If you do not currently use XSLT, no worries, we don't need to use it to get where we want to be. Can you show the line how you retrieve the CDATA that shows up as text?

The way the image will show up depends on where you place/load/put the output. I don't know, I need to see your code then first.

 

by: chefkeiferPosted on 2009-08-23 at 11:24:45ID: 25163622

i am assuming you need to see the code in AS...

the xml is just your basic xml..like the code above..the data is going into a textArea box..i had it going to a dynamic text box but the fonts were getting out of wack..i figure if i can get the image showing up then i would worry about the fonts and font size working right...

thanks for your help

var articleLb:List=articleList;
//-----------------------------------------------
var articles_xml:XML; //new XML
var xmlList:XMLList; //new xmlList
var xmlLoader:URLLoader = new URLLoader(); 
xmlLoader.load(new URLRequest("xml/articles.xml")); 
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded); 
//-----------------------------------------------
function xmlLoaded(event:Event):void{
		articles_xml=XML(event.target.data); 
		xmlList=articles_xml.children(); 
		for (var i:int = 0; i < xmlList.length(); i++) {
			articleLb.addItem({label: xmlList[i].articleName, data: i}); 
	}
		articleLb.addEventListener(Event.CHANGE, articleSelected);
		
function articleSelected(event:Event):void{
		articleName.text = xmlList.(articleName == articleLb.selectedItem.label).articleName;
		article.text = xmlList.(articleName == articleLb.selectedItem.label).article;
	}
}
//-----------------------------------------------

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:

Select allOpen in new window

 

by: abelPosted on 2009-08-23 at 11:37:44ID: 25163688

I have to admit that I'm not an AS programmer. My strengths are in XML, but I do a lot of JavaScript which is related, so let's see if we can fix this together.

If the "article" object is a textarea box and a textarea box is not supposed to interpret HTML, then try changing it to something that does allow HTML. You say your fonts went crazy, sounds to me that the font tag was actually working, at least a bit.

Let's stick with CDATA for a moment and try the crazy font again. If it does something font like, it finds the font tag (even if it goes wrong) and then it can find the <img> too, which we'll fix later. Try it with this, and perhaps you can screenshot what you've got and we take it from there (it will be enough information for me to understand whether we need to unescape or not).

<information>
        <articleName>Jan.25th Meeting Minutes</articleName>
        <article><![CDATA[                  
                <font size="14">This sizzling bikes shouting You know you wanna win me, take me, love me, ride MEEEE!!!! </font>]]>
        </article>
  </information>

                                              
1:
2:
3:
4:
5:
6:

Select allOpen in new window

 

by: chefkeiferPosted on 2009-08-23 at 11:53:17ID: 25163768

here is what happens..just the code shows up...not weird fonts...

i have attached a screen shot but it might be hard to read or you can just go to the site

www.drunkinswine.com/theCarolinaRider.php and click on then Stories & View Points, then click articles..its the second article that we are working with...

thanks again

 

by: abelPosted on 2009-08-23 at 11:59:34ID: 25163796

Ok, now I'm sure we're talking about the same subject.

Now, if we would remove the CDATA, the XML processor would see the <font> as nodes, not text. If we add them, like now, it is escaped text. Neither of these are handy. The actual path to a solution here is using innerText, but unfortunately that is not supported by ActionScript. Luckily someone created that: http://weblogs.asp.net/twalters/pages/10141.aspx (just copy the innerText method, or download his tools).

Then we can do the following: remove CDATA, and change that line like so:

article.text = xmlList.(articleName == articleLb.selectedItem.label).article.innerText;

and once that works, we can add the rest of the text and the image again.

 

by: chefkeiferPosted on 2009-08-23 at 12:08:46ID: 25163839

ok i have added that AS function to my code and also changed the one line you suggested..

i have also removed the CDATA from the one line of code in the xml..

i get no errors but now no text show up at all on either article..

here is the code to see if i missed something

AS-----
var articleLb:List=articleList;
//-----------------------------------------------
var articles_xml:XML; //new XML
var xmlList:XMLList; //new xmlList
var xmlLoader:URLLoader = new URLLoader(); 
xmlLoader.load(new URLRequest("xml/articles.xml")); 
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded); 
//-----------------------------------------------
XMLNode.prototype.innerText = function(){
 			var strText = "";
 			var xmlNode;
 			for( var i=0; i<this.childNodes.length; i++ )
 		{
  			xmlNode = this.childNodes[i];
		    switch(xmlNode.nodeType)
  		{
		   case 1: // elements
			strText += xmlNode.innerText();
			break;
		   case 3: // text
			strText += xmlNode.nodeValue;
			break;
		   default: // comments etc
			break;
  		}
}
 return strText;
};
//-----------------------------------------------
function xmlLoaded(event:Event):void{
		articles_xml=XML(event.target.data); 
		xmlList=articles_xml.children(); 
		for (var i:int = 0; i < xmlList.length(); i++) {
			articleLb.addItem({label: xmlList[i].articleName, data: i}); 
	}
		articleLb.addEventListener(Event.CHANGE, articleSelected);
		
function articleSelected(event:Event):void{
		articleName.text = xmlList.(articleName == articleLb.selectedItem.label).articleName;
		article.text = xmlList.(articleName == articleLb.selectedItem.label).article.innerText;
	}
}
//-----------------------------------------------
 
XML-----
  <information>
    	<articleName>Harley-Davidson Bike Giveaway</articleName>
    	<article>
		   <font size="14">This sizzling bikes shouting You know you wanna win me, take me, love me, ride MEEEE!!!! </font>
    	</article>
  </information>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:

Select allOpen in new window

 

by: IkluPosted on 2009-08-23 at 12:12:17ID: 25163854

Remove the CDATA tag and use
article.htmlText = String(xmlList.(articleName == articleLb.selectedItem.label).article);

The testfield must also be set to multiline and wrap text.

 

by: abelPosted on 2009-08-23 at 12:13:26ID: 25163860

Just to be sure it works, can you replace innerText with nodeValue of firstChild.nodeValue?

 

by: IkluPosted on 2009-08-23 at 12:14:23ID: 25163865

testfield = textfield
typo.

 

by: abelPosted on 2009-08-23 at 12:16:08ID: 25163870

Just noticed something, you need to set it to html = true and set the htmlText, apparently:

arcticle.html = true;
article.htmlText = ... your thing here

 

by: abelPosted on 2009-08-23 at 12:17:14ID: 25163875

Ah, Iklu, thanks for hopping in. Can you help with the AS specific bits? I started here, thinking it an XML issue, but it is apparently more an AS issue, and that's too many years ago... :)

 

by: IkluPosted on 2009-08-23 at 12:21:01ID: 25163884

Yeah it should work fine with the CDATA tag taken out, and using htmlText instead of text.  I don't believe you need article.html = true though because html isnt a property of the TextField class or its parent classes.  Im gonna test it in a sec.

 

by: IkluPosted on 2009-08-23 at 12:26:16ID: 25163902

Heres what I did and it worked fine for the article part.

var xml:XML = <information>
        <articleName>Jan.25th Meeting Minutes</articleName>
        <article><img src="http://www.drunkinswine.com/imagesTCR/carolinaMap.gif" height="250" width="250" alt="bikeGiveaway"/>                    
                <font size="14">This sizzling bikes shouting You know you wanna win me, take me, love me, ride MEEEE!!!! </font>
 
The picture was taken at Harley-Davidson of Charlotte where they are promoting their upcoming August 29th Red White and Brew, an event which is recently adopted by the dealership on Independence Boulevard.   Its a fourth annual event generated by Budweiser and first time at this venue.  Along with plenty to get folks there including a bike show and live music, venders and food, as well as the bike raffle of course; the events getting really revved up with something new and spicy: the finals of the local Karney Law Firm Daisy Dukes contest.  Plus, theres an after-party for the big Red White and Brew-day thats being held at McKoys Smokehouse on Old Pineville Road, the same location that will hold the Daisy Dukes Semi-Finals on Saturday, August 15th with live music, give-aways, and the usual out-of-this-world McKoys food and goodtimes atmosphere.    Registrations for the bike are taking place NOW.  Registrations for the Daisy Dukes contest are being taken by Jon Pendleton of Satisfaction Marketing.   For more information about all the events, check out www.h-dofcharlotte.com
 
        </article>
  </information>;
_txt.htmlText = xml.article;

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:

Select allOpen in new window

 

by: chefkeiferPosted on 2009-08-23 at 12:26:55ID: 25163906

i changed the following code and got the following error


1119: Access of possibly undefined property html through a reference with static type flash.text:TextField.

does this mean i cannot do this with a dynamic text box..or do i need to change this to a textArea component?

function articleSelected(event:Event):void{
		articleName.text = xmlList.(articleName == articleLb.selectedItem.label).articleName;
		article.html = true;
		article.htmlText = String(xmlList.(articleName == articleLb.selectedItem.label).article);
	}

                                              
1:
2:
3:
4:
5:

Select allOpen in new window

 

by: chefkeiferPosted on 2009-08-23 at 12:30:56ID: 25163922

ok it worked for me as well...now do i need to add the var and _txt part to every article that is in the xml file?

 

by: IkluPosted on 2009-08-23 at 12:31:06ID: 25163923

Yeah erase:
article.html = true;

 

by: IkluPosted on 2009-08-23 at 12:35:09ID: 25163940

The TextField I used named _txt was just a dummy TextField meant to represent the article TextField.

 

by: chefkeiferPosted on 2009-08-23 at 12:50:05ID: 25164000

everything is working just fine except for one thing...apostrophe do not show up on the text..is there a way to fix that?

 

by: IkluPosted on 2009-08-23 at 13:02:15ID: 25164028

I think its a bad character in your XML.  Try rewriting the apostrophe.  I tried looking at your XML file, but the server wouldnt let me because of errors in it.

 

by: chefkeiferPosted on 2009-08-23 at 13:05:53ID: 25164036

changing fixed it. It must have something to do with copy and pasting a word document to that section. i wish there was a way you could just right some code that would pull that word document in to the article part of the xml.

 

by: IkluPosted on 2009-08-23 at 14:18:05ID: 25164296

So everything works fine now?

 

by: chefkeiferPosted on 2009-08-23 at 14:45:28ID: 25164413

yes just fine...thanks for everyone's help

 

by: abelPosted on 2009-08-23 at 15:57:46ID: 25164636

Just checking back: glad you got it working! ;-)

 

by: abelPosted on 2009-08-24 at 03:55:18ID: 25167090

Ehrm, that's not a fair disposition towards Iklu, he helped a fair lot to get this to work. Can you request to reopen the q. and reassign the points, like a split between him and me?

 

by: chefkeiferPosted on 2009-08-24 at 04:02:45ID: 25167134

of course...like i said this is new to me...I will request it to be back open..any idea on how I do that..

 

by: abelPosted on 2009-08-24 at 04:38:13ID: 25167306

No problem, EE has a bit of "rules" and is a bit different than other forums in these respects. You can open your question by clicking "Request Attention" (next to your question) and then giving a small description on why you want it reopened. Usually, within 12 hours or so, a moderator will honor your request and you can choose your disposition again.

More on closing questions: http://www.experts-exchange.com/help.jsp?hi=407
More on splitting: http://www.experts-exchange.com/help.jsp?hi=100
More on reopening: http://www.experts-exchange.com/help.jsp?hi=404


-- Abel --

 

by: chefkeiferPosted on 2009-08-25 at 03:24:44ID: 31619383

thanks again sorry about the confusion with the points

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...