Cdata Formatting?
I'm using CDATA tags in XML to pass Flash html formatted text. Unfortunately using CDATA makes Flash take the text very literally (preserves line breaks, tabs, etc, etc) so I have to format the HTML as one long line. Is there a way to use CDATA to pass html formatted text and yet have it ignore line breaks, etc as a browser would with HTML? Perhaps even somehow removing those extra characters after it's loaded into Flash?
FlashKit > Flash Help > Flash MX
Posted on: 06-03-2003, 11:29 PM
View Complete Forum Thread with Replies
Sponsored Links:
CDATA - Still Not Formatting
Ok. I have searched the forum up and down and read about 6 different ways to supposedly add formatting to text through XML but nothing is working.
I have tried CDATA, I have tried URL encoding, and I have tried HTML encoding of '<''s and '>''s but still no luck. When I use CDATA around a block of text with a <b></b> in it, it will just show the <b> instead of parsing it.
I have html enabled on the text box. Did it through actionscript and then with the gui. I also tried embedding the font.
In dreamweaver it appears that the first <b> tag is closing the CDATA tag.
Here's my XML:
Code:
<![CDATA[TORONTO - A vegetarian diet high in fibre and low in saturated fats can lower cholesterol levels as effectively as some drugs, according to a new Canadian study. The study suggests some people should forgo medication in favour of the diet to control their cholesterol.
Researchers from the University of Toronto followed 46 people in the study. The participants averaged 59 years of age, all had high blood pressure and were overweight. They were split into three groups: one group followed a special diet, dubbed the Portfolio Diet, designed by the scientists; others followed a diet low in saturated fats (beef, butter) and used the cholesterol-lowering drug lovastatin; the last group ate a low-fat diet but didn't take the drug.
<b>Sample Diet <b>
Snack: Almonds, fruit, soy beverage
Dinner: Tofu bake with eggplant, onions and peppers, vegetables and pearled barley
Those on the Portfolio Diet ate foods with a lot of viscous fibre such as barley, oatmeal, okra and eggplant. The diet is based on one created by Dr. David Jenkins, known for his Garden of Eden diet plan of berries and roots. This time, Jenkins' team decided to make the diet more varied and to test the results. "This diet has got the right sort of mix of tolerability and effectiveness to suit a number of people," said Jenkins.
The team discovered:
* Those on the Portfolio Diet saw a 28.6 per cent reduction in their LDL (low-density lipoprotein) cholesterol levels just after one month;
* Those on the low fat diet with the drug achieved a 30.9 per cent reduction over the same period;
* Those just eating a low fat diet saw an eight per cent reduction.
LDL cholesterol is responsible for the fat layers that build up inside the walls of blood vessels causing hardening of the arteries and heart disease.
Researchers say there's little difference between the two groups and conclude that their diet has the same effect as the drug.
The study is published in the Journal of the American Medical Association.]]>
Is there any way short of creating a function to read the string and somehow replace the <b>Sample Diet</b> with <b>+"Sample Diet"+</b> ?
View Replies !
View Related
CDATA Xml Formatting
this is my xml row and i wish to apply html formatting to info parameter at the end of line.
<marker name="Amar Yatri Niwas" address="Tourist Complex Area, Fatehabad Road," address2="Agra - 282001, Uttar Pradesh, INDIA" lat="27.160835" lng="78.033607" id="2" thumbpath="" type="hotel" category="3 Star Hotel" web="www.hotelamar.com" info="test2" />
TO
info="<b>test</b> <a href="test.htm">i am online</a>"
can anyone tell me how would i do that ?
i know CDATA but i tried all the way and it didnt worked so i hope someone could help me here.
plz urgent help needed.
View Replies !
View Related
XML And CDATA Not Formatting As HTML Text
Last edited by yakken : 2007-12-16 at 20:37.
I have a site that uses XML to load text, pics etc. but I have a problem using the CDATA tag in my XML files and afterwards rendering the text as HTML.
The XML could be
HTML Code:
<?xml version="1.0" encoding="UTF-8"?>
<events>
<event pic="largePicture.png" header="Headline" caption="Subheadline" smallpic="thumbnail.png">
<description>
<![CDATA[<b>I would like to use HTML here</b><br>Next line!]]>
</description>
</event>
</events>
Loading the XML works fine and I have everything saved in arrays (the text I need here, would be in the "descriptions" array - see below), that I can access, but when I try to throw my the <description> content into a textbox, it displays everything as it is typed above - including the tags etc. I would be setting up the text like this (taken out of context and boiled down a bit to make it easy on the eye):
ActionScript Code:
//this is the i'th element that I am loading
["mc_text"+i].descrip.html=true;
["mc_text"+i].descrip.multiline = true;
["mc_text"+i].descrip.autoSize = true;
["mc_text"+i].descrip.htmlText= descriptions[i];
where the "decrip" text field would be the one containing my text.
It does, however, not format my text as HTML (the autosize attribute works though). A direct link to one of the subpages, not showing my text properly is here: http://www.vanity.dk/oceanclub/test.swf
Pres the last button on the right...
Help is appreciated!
I can see that this guy seems to have the same troubles as I:
HTML Links in xml.
but none of the suggestions in that thread seems to do the trick
View Replies !
View Related
MX2004: XPathAPI CDATA SelectSingleNode And HTML Formatting
Hello,
my subject is pretty much my problem, i am using MX2004's XPathApi 'selectSingleNode' which is working nicely, i have done a wee bit of fiddling;
Code:
_root.selectedText = "About Us "
centreMe.textContent.htmlText = mx.xpath.XPathAPI.selectSingleNode(this.firstChild, "/data/item[@name = '"+ _root.selectedText + "']/*");
I would like to be able to change the content depending on what the variable is, and this seems to work fine. The content should be formatted text (with <p> etc...), so i am using CDATA tags to make sure no confusion is made with <>'s (and if i dont it only pulls in a small section - as expected).
Only problem is that for some reason it forgets it is a html formatted bit of CDATA and spits out the <p> tags with the rest of the content... i have placed in "centreMe.textContent.html = true;" make sure it knows its html but it really doesnt want to know.
I tried using selectNodeList to an array and printing this - which works, without CDATA tags, but adds a really annoying "," at the end of each "array item" it is printing.
Any help would be fantastic as i have also been through an entire saga to get here trying different techniques to get html tags displaying correctly within CDATA - and i guess this is ultimately my problem?
Thanks for your time!
Løque
--------
edit > now i am having a really "noobie" problem (if my one above wasnt already enough)
this works;
Code:
bla.html = true;
bla.htmlText = "this is frustrating?";
but this doesnt display anything in my dynamic textbox;
Code:
bla.html = true;
bla.htmlText = "<b> this is frustrating?</b>";
why does actionscript hate me? its player 7 with as2
View Replies !
View Related
CData And RSS
Hi...
I load the CData with
description=weatherXML.firstChild.firstChild.child Nodes[12].childNodes[6]
but when I tried to retrieve them:
weather_mc.descr.html=true
weather_mc.descr.htmlText+=description
weather_mc.descr.htmlText+="just to try <img src='http://l.yimg.com/us.yimg.com/i/us/we/52/35.gif'/>"
the second line appera perfectly...
the first instead (description), appear as html
any guess?
View Replies !
View Related
Xml & Cdata
Hi everybody,
I have a problem with filling textField from xml data
I'm using CDATA to allow html text inside the xml source (I read that everything is inside CDATA is ignored by xml parser) but i doesn't work properly. When I populate textFields in flash I still see the tags I used into CDATA. i.e. <b> text</b>
this is the as code I used in flash:
Code:
myxml = new XML();
myxml.ignoreWhite = true;
myxml.load("sara.xml");
myxml.onLoad = function(success) {
if (success) {
trace("success");
process(0, 0);
}
};
process = function (i, j) {
var txt = myxml.firstChild.childNodes[i].childNodes[j].childNodes[0];
this.createTextField("testo", 11, 0, 0, 400, 300);
this.testo.html = true;
this.testo.background = true;
this.testo.backgroundColor = 0xff0000;
this.testo.wordWrap = true;
this.testo.multiline = true;
this.testo.htmlText = txt;
};
And this is the xml source:
HTML Code:
<?xml version"1.0" encoding="utf-8"?>
<item>
<contacts>
<a titolo="text"><![CDATA[text text <b>text</b> text text text]]></a>
<b titolo="text">sometext</b>
<c titolo="text">more text</c>
</contacts>
</item>
Is there anyone who can explain me where I do wrong?
thanks a lot
View Replies !
View Related
Xml Cdata
I am beginning to learn XML and I have made an image gallery with XML, I was wondering if someone could point me in the direction to learn how to have text descriptions with the photos that are loaded.
I have figured enough out to know that I can add a description in the xml as cdata. Although I can't find resources on how to display this on the photo when its loaded.
Thanks
View Replies !
View Related
CDATA And XML
I have a swf that get's its content from a XML file. I need some of the content to be html so I can use italics. Here's some of my xml:
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<content>
<mainimage>images/tour_map/tour_map_main.jpg</mainimage>
<title>Tour Destinations Map</title>
<item>
<title><![CDATA[Some <i>fancy html</i> text]]</title>
<description>A description</description>
<photo>images/banner/image1.png</photo>
<thumb>images/banner/thumb_SLE-Astronauts.jpg</thumb>
<button1text>Learn More</button1text>
<button1link>http://www.reddit.com</button1link>
<button2text>Buy Tickets</button2text>
<button2link>http://www.google.com</button2link>
</item>
<item>
<title>A title</title>
<description>A description</description>
<photo>images/banner/image2.png</photo>
<thumb>images/banner/thumb_ATX-Students.jpg</thumb>
<button1text>Learn More</button1text>
<button1link>http://www.reddit.com</button1link>
<button2text>Buy Tickets</button2text>
<button2link>http://www.google.com</button2link>
</item>
</content>
</xml>
I'm then trying to place all of this into a dictionary which works fine. Here's my XML loader stuff:
Code:
stop();
//declare variables
var xmllocation:String;
var dict:Dictionary = new Dictionary();
import flash.utils.*
//xmllocation = root.loaderInfo.parameters.fvXMLLoc;
xmllocation = "banner.xml";
//xml
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest(xmllocation));
var i2:uint=1
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
var itemList:XMLList = xmlData.item;
for(var i:uint=0; i<5; i++){
dict["item"+i2+"title"] = itemList[i].title.text();
dict["item"+i2+"description"] = itemList[i].description.text();
dict["item"+i2+"photo"] = itemList[i].photo.text();
dict["item"+i2+"thumb"] = itemList[i].thumb.text();
dict["item"+i2+"button1text"] = itemList[i].button1text.text();
dict["item"+i2+"button2text"] = itemList[i].button2text.text();
dict["item"+i2+"button1link"] = itemList[i].button1link.text();
dict["item"+i2+"button2link"] = itemList[i].button2link.text();
i2++;
}
gotoAndPlay(2);
}
Problem is that I get this error:
TypeError: Error #1091: XML parser failure: Unterminated CDATA section.
at banner_fla::MainTimeline/LoadXML()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
What am I doing wrong?
View Replies !
View Related
CDATA In XML
I am trying to place an html link in my xml document like so -
<slideshow>
<photo url="image1.jpg" caption="<![CDATA[<BR><A HREF='http://www.exittheonramp.com'></B>exitTheOnRamp]]>" </photo>
my text box in the swf allows html formating.
when i take the CDATA stuff out and just use text everything does work fine.
Am i missing a step?
Any suggestions or comments will be rad.
Thanx.
View Replies !
View Related
XML CDATA In MC
Hi, there..
I need to load some CDATA txt in a dyn field.
Txt of the node is:
Code:
<Info><![CDATA[<b>Some text</b> text.<li>Some text is/li> ]]></Info>
Here it works work.
Code:
info.htmlText = go.childNodes[2].childNodes;
Here it won't.
Code:
mc1.info.htmlText = go.childNodes[2].childNodes;
Futher i tried:
XML FILE : <?xml version="1.0" encoding="UTF-8"?>
Embed fonts/ Render txt as HTML.
Others: System.useCodepage = true;
Please some got ideas? Why it won't work in a MovieClip.
View Replies !
View Related
Cdata And Xml
Are there any special things I have to do in order to get CDATA to work so I'm able to use apostrophe's with text I bring in from a mysql database?
Basically all I'm doing is making a .php file that echo xml tags and brings in the data. Then I set a CDATA tag between the xml tags where it's needed but it still brings in apostrophe's and stuff as &APOS;; when I load it into flash.
Am I missing something? Is it because I'm running it from a .php file instead of .xml?
Any help would be greatly appreciated!
View Replies !
View Related
Any Way To Get Around Having CDATA In Xml?
So i stand corrected. the <a href is screwing up my XML data.
If I plop a CDATA tag in the XML obviously it works fine. But is there any other options to keep that tag out of the XML file?
If I can somehow include it in Flash (which logically doesn't make sense) that would be great.
Any idea's? The XML is generated server side and I can't get them to mod it.
View Replies !
View Related
CDATA And XML
I have a swf that get's its content from a XML file. I need some of the content to be html so I can use italics. Here's some of my xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<content>
<mainimage>images/tour_map/tour_map_main.jpg</mainimage>
<title>Tour Destinations Map</title>
<item>
<title><![CDATA[Some <i>fancy html</i> text]]</title>
<description>A description</description>
<photo>images/banner/image1.png</photo>
<thumb>images/banner/thumb_SLE-Astronauts.jpg</thumb>
<button1text>Learn More</button1text>
<button1link>http://www.reddit.com</button1link>
<button2text>Buy Tickets</button2text>
<button2link>http://www.google.com</button2link>
</item>
<item>
<title>A title</title>
<description>A description</description>
<photo>images/banner/image2.png</photo>
<thumb>images/banner/thumb_ATX-Students.jpg</thumb>
<button1text>Learn More</button1text>
<button1link>http://www.reddit.com</button1link>
<button2text>Buy Tickets</button2text>
<button2link>http://www.google.com</button2link>
</item>
</content>
</xml>
I'm then trying to place all of this into a dictionary which works fine. Here's my XML loader stuff:
Code:
stop();
//declare variables
var xmllocation:String;
var dict:Dictionary = new Dictionary();
import flash.utils.*
//xmllocation = root.loaderInfo.parameters.fvXMLLoc;
xmllocation = "banner.xml";
//xml
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest(xmllocation));
var i2:uint=1
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
var itemList:XMLList = xmlData.item;
for(var i:uint=0; i<5; i++){
dict["item"+i2+"title"] = itemList[i].title.text();
dict["item"+i2+"description"] = itemList[i].description.text();
dict["item"+i2+"photo"] = itemList[i].photo.text();
dict["item"+i2+"thumb"] = itemList[i].thumb.text();
dict["item"+i2+"button1text"] = itemList[i].button1text.text();
dict["item"+i2+"button2text"] = itemList[i].button2text.text();
dict["item"+i2+"button1link"] = itemList[i].button1link.text();
dict["item"+i2+"button2link"] = itemList[i].button2link.text();
i2++;
}
gotoAndPlay(2);
}
Problem is that I get this error:
TypeError: Error #1091: XML parser failure: Unterminated CDATA section.
at banner_fla::MainTimeline/LoadXML()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
What am I doing wrong?
View Replies !
View Related
Xml, Css, And CDATA
ive read all the posts on this subject, but am wondering if its possible to load xml, style it with css, but instead of the html bit being in a seperate node, is it possible to have the html in an attribute? something like:
Code:
<item image=".../images/1.jpg" title="Image 1" caption="<h1>This</h1> is image<br>1" />
the caption bit throws an error.
anybody ever tried this?
View Replies !
View Related
Output Cdata
Good afternoon everyone.
Im looking for a way to output XML Cdata nodes to my asp.
I have created a Content Management system that allows the user to format text using html tags - so far so good. However to retain the html tags i would like to save the data withing Cdata nodes.
Everytime I try to do this certain characters are escaped, and this seems to me to be a waste of time as I might as well escape the whole thing. I dont want to have to urlencode all my data before it goes into an xml node.
View Replies !
View Related
Problems With <[CDATA[
Can anyone help me with this? I have an XML doc with a node that contains CDATA and when I try to put it into a dynamic HTML text field I get the whole url string rather than just the text that I want to show. What am I doing wrong?
<name><![CDATA[<a href="http://www.mylink.com"><u>Perma Magazine Files</u></a>]]></name>
View Replies !
View Related
Importing XML Containing CDATA...
Hi, sorry if this has been asked before, but I've searched high and low and can't find a solution.
I've got a text field that is set up to handle HTML and this works perfectly when importing from a text file or reading from a variable.. the problem occurs when I'm importing data from an XML document. The XML document contains HTML formatting in certain elements therefore I've used CDATA to contain this data correctly without affecting the XML structure. However, i've noticed when importing the data to an array, the HTML is coded as:
<p>text goes here</p>
instead of
<p>text goes here</p>
What do I need to do in order to prevent this from occuring?
Many thanks for any help!!
View Replies !
View Related
XML And CDATA Question.
I am currently trying to add the function for a link to this particular project from FLASHKIT:
http://www.flashkit.com/movies/Compo...2030/index.php
I am not aware of where the corresponding elements exist int hte projects structure to edit them and add the relevant code for turning the photos in the slide show into elements that can link to a URL.
Any hints or direction would be welcomed.
Thank you.
View Replies !
View Related
CDATA Question In AS
Hi, I have a .xml file with several text fields.
<?xml version="1.0" encoding="UTF-8"?>
<text1>some text1</text1>
<text2>some text2</text2>
This is my code in .fla file:
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function(success:Boolean) {
var rtTxt1:XMLNode = this.firstChild;
var text1 = rtTxt1.firstChild;
//trace(text1);
var rtTxt2:XMLNode = this.firstChild.nextSibling;
var text2 = rtTxt2.firstChild;
//trace(text2);
textload(text1, text2);
};
xml.load("desc.xml");
textload = function (t1, t2) {
text1_txt.text = t1;
text2_txt.text = t2;
};
Can somebody write me in AS code that enables html text in xml file?
And I don't know how tu use a simple CDATA code. For example a basic url?
View Replies !
View Related
[CS3] Read CDATA
I want flash to read the node content inside CDATA also "along with the word CDATA".... i tried all possible ways, but its only able to read the nodevalue alone. Please help !!
example if i use, firstChild.firstChild.firstChild.nodeValue, it will read "Click <b>this</b> to continue.".. when i use firstChild.firstChild.childNodes[0] it will read everything inside <text></text> EXCEPT CDATA..... But i want this also.
Quote:
<sb:cse><text><![CDATA[Click <b>this</b> to continue.]]></text></sb:cse>
View Replies !
View Related
XML CDATA Working With < Or >
I am using text from an xml file, but the CDATA isn't working like its supposed to. I first noticed this when I tried to make an email link, all text after the link was displayed. So now I put some test text in there and nothing shows up after <>.
Any Suggestions?
XML File
Code:
<menu title="Pre-Training" msg="Please select a link from the left">
<menuItem linkName="About Us">
<content linkName="I am a content page residing in branch 1" >
<![CDATA[If there is a discription the it will go here. Cdata alows me to use "',<>/ anything i want"]]>
</content>
</menuItem>
<menuItem linkName="My New Identity">
<content linkName="I am a content page residing in branch 2" url="path/to/file.pdf">
<![CDATA[If there is a discription the it will go here. Cdata alows me to use "',<>/ anything i want"]]>
</content>
</menuItem>
</menu>
AS 3 code
Code:
var docDesc_txt:TextField = new TextField();
docDesc_txt.y = docTitle_txt.y+docTitle_txt.height+5;
docDesc_txt.multiline = true;
docDesc_txt.wordWrap = true;
docDesc_txt.autoSize = "left";
docDesc_txt.width = 375;
docDesc_txt.htmlText = linkList[brachNo].content[j];
docDesc_txt.setTextFormat(docDesc_frmt);
content_mc.addChild(docDesc_txt);
View Replies !
View Related
CDATA Issue
I've read the post on why CDATA with html tags are not reading formating the text, but I still can't get it to work.
code concerning the xml.
Quote:
var moduleRollOverFormat:TextFormat = new TextFormat("Menu-Font", 16, 0xcccccc);
var txt:String = structure[mod-1].description.split("\n").join("
");
var popup:MovieClip = _root.createEmptyMovieClip("popup"+mod+"_mc", 11000+mod);
popup._alpha = 0;
popup._x = 524;////345; ////120
popup._y = 270;
// Create textfield
popup.createTextField("label_txt", 10, 30, 30, 425, 50);
popup.label_txt.html = true;
popup.label_txt.embedFonts = true;
popup.label_txt.autoSize = true;
popup.label_txt.wordWrap = true;
popup.label_txt.multiline = true;
popup.label_txt.selectable = true;
popup.label_txt.width = 425;
popup.label_txt.setNewTextFormat(moduleRollOverFor mat);
popup.label_txt.htmlText = txt;
XML
Quote:
Quote:
<?xml version="1.0" encoding="utf-8"?>
<subject>
<course title="New One>
<description><![CDATA[<u>Make this underline.</u> not this text. ]]></description>
</course>
</subject>
Most of the post says that my var string needs to have the nodeValue how do I do change this to look for the node value?
Quote:
var txt:String = structure[mod-1].description.split("\n").join("
");
or is it something else that I should be doing? Thanks
View Replies !
View Related
CDATA And Hyperlinking
Hi--
I have read through a lot of posts and tutorials about this and feel I have a lot of 'pieces' but am not sure how to set up xml with cdata tags that function as a hyperlink in Flash. Here is my xml:
Code:
<?xml version='1.0' encoding='utf-8'?>
<data>
<title>demo gallery small</title>
<thumbnail base="_content/thumbnails/" />
<large base="_content/images/" />
<images id="images">
<image imagewidth='319' imageheight='169' thumbwidth='40' thumbheight='30' path='trowley-01.jpg' thumbnail='trowley_TN.jpg' date='2005-01-12 21:34:03 -0500' ranking='0'>
<item><![CDATA[This is a Flash based site for Trowley Arts.<A HREF='http://www.trowley.com'><font size="8" color="#0000ff"><u>click here to launch</u></font></A>.]]></item>
</image>
</images>
</data>
I am using 2.0 classes to parse the xml(which works fine) but I don't know how to reference the cdata tags to get to the nodeValue. Here is what I have - returns undefined:
ActionScript Code:
caption_txt.text = myxml.firstChild.childNodes[0].childNodes[0].childNodes[0].nodeValue;
Any help would be appreciated.
Thanks
View Replies !
View Related
Loading Url Using Xml CDATA
I want to load images/urls dynamically from xml. I'm using xml CDATA but still can't load.
Also I'm attaching a movieclip and want to display the image(the one being loaded) related info in a text field in the movie clip attached to the mouse, so i can have a 'mouseover help tip' kind of effect on each image.
I don't what I'm doing wrong but it's not working Please help
my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.load("gallery.xml");
my_xml.onLoad = function(success) {
if (success) {
for ( var i=0; i<my_xml.firstChild.childNodes.length; i++) {
url = my_xml.firstChild.childNodes[i].childNodes[1].nodeValue;
loadMovie(url, ["mc"+i]);
}
}
};
function info() {
if (mover) {
this.attachMovie("star", "pointer_mc", this.getNextHighestDepth());
//Mouse.hide();
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
pointer_mc._x = _xmouse+5;
pointer_mc._y = _ymouse-5;
updateAfterEvent();
};
Mouse.addListener(mouseListener);
for (var i=0; i<my_xml.firstChild.childNodes.length; i++) {
pointer_mc.myname.html = true;
pointer_mc.myname.htmlText = my_xml.firstChild.childNodes[i].childNodes[0].nodeValue;
}
} else {
this.pointer_mc.removeMovieClip();
}
}
View Replies !
View Related
XML CData In Actionscript
I am a Delphi/C++ programmer and a complete newcomer to Flash. I am in the process of writing server side components to control client side interfaces that can be either a Win32 executable, AJAX or Flex. Given this I am constraining all the server-client communications to be XML documents. The question I have is this
Would Actionscript (I may never do AJAX so it does not bother me so much) provide any methods I could use to convert WMA or PNG files provided in CDATA sections of my XML documents into binaries that I could then play/display in Flex at will?
If this is possible is there any constraint on how the file should be encoded? (Hex vs 64?)
I would much appreciate any help.
View Replies !
View Related
Using The XML Object And CDATA
i have an XML object, which I declare in the following way:
ActionScript Code:
var requestXmlBodyItem:String = new String();
requestXmlBodyItem = '<?xml version="1.0" encoding="utf-8" ?>';
requestXmlBodyItem += '<Parent1 xmlns="urn:apis:eBLBaseComponents">';
requestXmlBodyItem += "<Child1><Child2>"+someVar+"</Child2></Child1>";
requestXmlBodyItem += "</Parent1>";
//create the XML
var requestXMLItem:XML = new XML(requestXmlBodyItem);
The variable in red ("someVar") is a string of HTML tags. After quite a bit of searching, I have found that I need to use CDATA...
my question is, how can I do this?
View Replies !
View Related
XML, CDATA And ParseXML
Has anyone has trouble with using CDATA tags in XML and parsing the source XML string into and XML object where the data between CDATA tags is being altered by the Flash Player?
ActionScript Code:
var source_Without_CDATA : String = "<test>Hello<br>world</test>";
var source_With_CDATA : String = "<test><![CDATA[Hello<br>world]]></test>";
var xml : XML = new XML();
xml.parseXML( source_With_CDATA );
trace( xml );
// with CDATA traces: <test>Hello<br>world</test>
// without CDATA traces: <test>Hello<br>world</br></test>
Any input appreciated.
View Replies !
View Related
XML <[CDATA[ ]] Usage
Hello!
I'm having some trouble with this issue. I'm developing a xml feeded web site, and in one of the areas I have this in the XML file:
<sometag>
<![CDATA[<b>some bold text here would be nice</b>]]>
</sometag>
Somehow this should show me a bold text in flash (all the textfields are html)
but what I get is the <b>some bold text would be nice</b>
Can anyone point me in a good direction? or why this is happening?
All the best
View Replies !
View Related
XML/CDATA Problem In IE Vs. FF
I'm having a problem with XML.toXMLString() when running in FF/Safari vs. IE.
Say I have a chunk of XML with a CDATA section:
ActionScript Code:
private var _xml:XML =
<test>
<![CDATA[
<message>Hello World</message>
]]>
</test>
if I print it out with toXMLString() I get the following in IE:
ActionScript Code:
<test>
<message>Hello World</message>
</test>
The CDATA is stripped out and the brackets are encoded.
When I do toXMLString() in FF/Safari I get:
ActionScript Code:
private var _xml:XML =
<test>
<![CDATA[
<message>Hello World</message>
]]>
</test>
Any one have any ideas on why running my SWF in IE causes the CDATA tag to be stripped and the brackets to be encoded?
View Replies !
View Related
XML CDATA Issue
Hi all,
I'm having an issue with Flash/AS3 where my CDATA is not being recognized by htmlText in situations where the cdata is located in an element that has one or more nodes.
for example, I can see all of the text within the CDATA block when I set a TextArea's htmlText to xml.sentence:
(xml)
Code:
<text>
<sentence>
<![CDATA[ Here is a bunch of text. And here is a little more: <, >, &, " and ' with no problem. Expecting a third line? Neither was I!]]>
</sentence>
</text>
however, when I add a node or two within the <sentence>, element, the CDATA doesn't show up in the htmlText:
Code:
<text>
<sentence>
<someNode>This is the only thing that will show up now.</someNode>
<![CDATA[ Here is a bunch of text. And here is a little more: <, >, &, " and ' with no problem. Expecting a third line? Neither was I!]]>
</sentence>
</text>
I have always been able to trace everything in the xml. I would like both the CDATA text and the text in the <someNode> to show up in the htmlText when I set it equal the <sentence> element. The <someNode> is supposed to be formatted differently (e.g, if I want the content in <someNode> to use the <a> html tag) but in the same sentence.
Can anyone explain what is going on here and/or how I can solve this issue?
Thanks in advance
View Replies !
View Related
XmlList And CDATA
Hey Everyone,
I'm running into an issue that I've just noticed in a 95% complete project. The xml I'm pulling from has a person which contains 3 attributes, an image, a description and a name. After loading in the descriptions I noticed that I was losing my punctuation, commas, apostrophe, etc. I did some googling and found it was the xml parser, so I tried the escape char ' but no luck. I did some further digging and found that it would be better to wrap the description in a CDATA tag. This bring me to my question, how to I access the content inside the cdata tag from an xmllist? Since this project is nearly complete it would be a massive headache to go back and remove the xmllist from the code. This is my first xml heavy project so please forgive any newbness.
Thanks in advance.
View Replies !
View Related
CDATA Not Working ?
For any one that chooses to help me thank you
I am bring in data from an xml file...
Here is the xml:
Code:
<?xml version="1.0" encoding="iso-8859-1" ?>
<contact>
<name>test</name>
<phone>555-1212</phone>
<email><![CDATA[<p>test@test.com</p>]]></email>
<web><![CDATA[<p>http://www.test.com</p>]]></web>
</contact>
When I bring the information in to flash MX it is converting
MJy trace is displaying my p tags as "<":
Quote:
-<p>test@test.com</p>
-<p>http://www.test.com</p>
Is there any thing I am doing worong?
Here is my parse code:
ActionScript Code:
fscommand("allowscale", "false");
content = [];
step = "1";
XML_var = new XML();
XML_var.ignoreWhite = true;
XML_var.load("contact.xml");
XML_var.onLoad = parseXML;
txt = "Loading XML data...";
function parseXML() {
var t = this.firstChild.childNodes;
_global.ContactName = t[0].childNodes
_global.ContactPhone = t[1].childNodes
_global.ContactEmail = t[2].childNodes
_global.ContactWeb = t[3].childNodes
trace("t = " + t);
trace("t.length = " + t.length);
trace("t[2].childNodes = " + t[2].childNodes);
trace("_global.ContactWeb = " + _global.ContactWeb);
play();
}
Steve
[EDIT/CyanBlue]
Please use the proper code syntax to format the code.
Read this page to find out more about the tag information
[/EDIT]
View Replies !
View Related
CDATA In Flash MX // XML
Can the cdata function be used in actionscript to pull xml data
![CDATA[firstChild.firstChild.attributes.item]];?
Is this possible to do? I have an ampersand that I am attempting to bring into my movie and it keeps bonking...with bunk data...
Example
<z: row name="peanuts & yams" id="py" />
and it comes in with peanuts&@26 or something like it...It doesn't seem to happen on my machine...but I have watched it happen on my co-workers machines...
3l337
View Replies !
View Related
CDATA And XML Parameters
Hi,
I am battling to use the CDATA tags to allow me to embed html formatted content in my xml attributes.
I am generating this info with ASP and am trying to use the Spark Events Calendar flash Component to show the information. It works fine until I add a line break or any notation including "<>" and then the Calendar displays no info.
I have read several posts pertaining to the use of CDATA and using it to enclose entire nodes. The only parameter that will have any kind of html descriptive info in is the "description" parameter. If I enclose the whole node with CDATA then it becomes invisible to flash.
This is what the node looks like
HTML Code:
<event title="<%=(rs_events.Fields.Item("Event_Title").Value)%>" description="<%=(rs_events.Fields.Item("Event_Content").Value)%>" eventID="<%=(rs_events.Fields.Item("Event_ID").Value)%>" >
</event>
Any advice on resolving this problem would be hugely appreciated
Thanks
Gregg
View Replies !
View Related
CDATA Enquiry
Hi
A have an enquiry regarding parsing html formatted text from an xml file.
I know how to do this using CDATA when the text is contained within its own node. However in this case the text is an attribute of a node like this:
Code:
<myNode number="01" title="My Node" text="This is where i want the html formatted text to go.">
Can anyone help me with this? I really dont want to have to alter the xml structure but will if it is the only way.
Thanks
View Replies !
View Related
CDATA With Flash
I'm trying to make some of the text in my XML bold and italic. I read that you need to use CDATA to make it so the tags actually work but I'm having issues with it working. Here is my XML (with what i want to be bold)
Thanks!
Attach Code
<?xml version="1.0" encoding="utf-8"?>
<gallery name="houses">
<item dir="AppleAlley/" name="Apple Alley" location="Milford, PA" desc="This newly-built shingle-style Victorian house was inspired by an historic photograph of the building that had occupied its site for nearly one hundred years. The interior has been re-imagined for modern living, with an open kitchen and generous living areas that comfortably accommodate large family gatherings.
<b><i>Project Under Construction</i></b>">
<image file="apple_alley_1.jpg" />
<image file="apple_alley_2.jpg" />
<image file="apple_alley_3.jpg" />
</item>
</gallery>
View Replies !
View Related
Parsing CDATA
Am I missing something simple? The research I've done all say that reading cdata from an xml in flash is easy, so they don't explain how. Here's my problem. Node looks like this:
<DDATE>
<#cdata-section>2007-06-19 14:38:58.0</#cdata-section>
</DDATE>
but when I try to convert it to a string (mystring=xml.node.DDATE) I get the above (which I'm going to go ahead and parse today for what I need). If I try to parse xml.node.DDATE.child, .firstChild, or .text all I get is empty string "". I can't try xml.node.DDATE.#cdata-section because that creates a compiler error
Any thoughts?
Thanks.
View Replies !
View Related
XML: <[CDATA[ >still Not Showing ]]>
Hi,
I have a beginner's XML question. I use this XML code:
Code:
<news>
<kop1><![CDATA[Concert Kasabian afgelast >>>]]></kop1>
</news>
I was being told that using <![CDATA[ ]]> would allow me to type anything in between, even the '>' symbol. But helais, I still get to see '>' when I publish.
My as:
ActionScript Code:
var my_xml = new XML(); my_xml.ignoreWhite = true; my_xml.onLoad = function(ok) { if (ok) { var field = NK1MC.NK1; field.multiline = true; field.wordWrap = true; field.autoSize = true; field.selectable = false; field.text = this.firstChild.childNodes[0].firstChild; field.setTextFormat(NK1fmt); } }; my_xml.load(txt);
(by the way, how should I wrap XML code on this forum?)
Could someone explain to me why the CDATA code doesn't work for me?
thank you,
Jerryj.
View Replies !
View Related
CDATA Links In XML
Good morning (from New York City) experienced Flashers...I need a lil assistance...
I need to have two links in an XML document. This XML document would be loaded into Flash.
The first link I would need is a mailto: link for e-mail. The second link would be a regular hyperlink. Now, first, how could I accomplish this? Render the text as html I was told, but how should write the links? Does Flash have to parse such data?
Any form of help would be definitely appreciated...
View Replies !
View Related
CDATA Not Working...
I've already searched and done every possible thing to get this bold to work.
Ive tried using <b>, <strong>,<bold> etc..nothing happens
My text field is 11pt verdana, bitmap text, HTML enabled.
Here is my AS
PHP Code:
var dev1Length = _root.rackxml.firstChild.firstChild.childNodes[0].childNodes.length;for (i = 0; i < dev1Length + 1; i++) { this["btn"+i].id = i; this["btn"+i].onRollOver = function() { loadItem(this.id); } }function loadItem(itemID) { var rackValue = _root.rackxml.firstChild.firstChild.childNodes[0].childNodes[itemID].firstChild.nodeValue; _parent.rackTxtMC.rck.html = true; _parent.rackTxtMC.rck.htmlText = rackValue;}
The text is showing up fine, but no tags are being enabled. Here is an example node that I am loading in.
PHP Code:
<btn5><![CDATA[<b>Hardware</b>: Cisco 515 Primary FireWall - 1U]]></btn5>
getting really frustrated
View Replies !
View Related
Help On CData In XML And Flash
I wanted to navigate my flash menu with my xml. How should I input the CData code in flash?
This is the code in my xml file:
Code:
<link name="SIDE ORDERS" ref="<![CDATA["gotoAndStop(3);"]]>"/>
And here's my Flash menu scripts:
Code:
var yPos = 0;
var depthCount = 1;
var linksXML = new XML();
var xml_loaded = "menu.xml";
linksXML.ignoreWhite = true;
linksXML.load(xml_loaded);
linksXML.onLoad = checkLoading;
function checkLoading(success) {
if (success == true) {
var rootNode = linksXML.firstChild;
var total = rootNode.childNodes.length;
//Load the links Text
var tLink = rootNode.firstChild;
for (i=0; i<total; i++) {
createLink("tLink"+i,tLink);
var totalInner = tLink.childNodes.length;
var tnLink = tLink.firstChild;
for (j=0; j<totalInner; j++) {
createLink("tnLink"+j+""+i,tnLink);
tnLink = tnLink.nextSibling;
}
tLink = tLink.nextSibling;
}
gotoAndStop(2);
}
}
function createLink(newObj, aNode) {
duplicateMovieClip(this.baseLink, newObj, depthCount++);
var tcl = eval(newObj);
tcl.aLink = aNode.attributes.ref;
yPos += 15;
if (aNode.nodeName == "link") {
setName(tcl,aNode.attributes.name,1);
tcl._x = 195;
} else {
setName(tcl,aNode.attributes.name,0.95);
tcl._x =195;
}
tcl._y = yPos;
}
gotoAndStop(1);
function setName(obj, theName, Size) {
obj._height = obj._height*Size;
obj._width = obj._width*Size;
obj.TextLink.BoxName.text = theName;
obj.TextLinkShadow.BoxName.text = theName;
obj.embedFonts = true;
//obj.TextLinkShadow._alpha = 20;
}
View Replies !
View Related
XML CDATA Issue
Hi all,
I'm having an issue with Flash/AS3 where my CDATA is not being recognized by the xml parser in situations where the cdata is located in an element that has one or more nodes.
for example, I can see all of the text within the CDATA block when I set a textArea's htmlText to myXML.sentence
(myXml)
Code:
<text>
<sentence>
<![CDATA[ Here is a bunch of text. And here is a little more: <, >, &, " and ' with no problem. Expecting a third line? Neither was I!]]>
</sentence>
</text>
however, when I add a node or two within the <sentence>, element, the compiler doesn't read the the CDATA at all.
Code:
<text>
<sentence>
<someNode>This is the only thing that will show up now.</someNode>
<![CDATA[ Here is a bunch of text. And here is a little more: <, >, &, " and ' with no problem. Expecting a third line? Neither was I!]]>
</sentence>
</text>
Can anyone explain what is going on here and/or how I can solve this issue?
Thanks in advance,
mightyRGB
View Replies !
View Related
CDATA Nodes
I want to generate CDATA in FlashMX.
I have tried just tagging it on when creating the node but this doesnt work.
Does anyone know how to do this?
View Replies !
View Related
Using CDATA And Links In XML
Ok i know this has been asked a million times but i'm gonna ask again
So here's the deal:
I've got my php gene ml file located at http://touchsun.freehostia.com/php/news.php which displays my xml nicely as intended
If you view the source of the ile you can see that i've added CDATA tags to the entry node. How the heck do i get flash 8 to parse the italics and break tags correctly? I've set htmlText = true to mytext fields using the property inspector and through actiosncript but it still won't pass these tags?
Instead i get "Today the official Touchsun website was launched!<br/>After much hard work planning and designing the site we finally hit the enter key and uploaded the final copy to the server! Feel free to browse around and we hope that you enjoy the <i>official</i>Touchsun website"
How do i use these tags? am i using CDATA correctly or not?
View Replies !
View Related
CDATA With The Use Of XML Attributes
hey everyone.
I have created a video player based on lee's tutorials, but instead of loading the movie list into a list component i've instead loaded them into a dynamic text box.
I need to make these links to the flv files clickable so that it will open the correct flv file. I've gathered that I need to use CDATA for this, but apparently it is not compatable with the use of attributes.
Can someone clarify on this, and maybe post an example of how to implement it if it is possible on this xml document.
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<videos>
<video url="http://www.jacksrambles.com/flv/episode0.flv" desc="Scuba Steve and Partner" />
<video url="http://www.jacksrambles.com/flv/episode1.flv" desc="Scuba Steve meets Evil Brother Bob" />
</videos>
I really need some help
cheers, JacoX
View Replies !
View Related
Problems With CDATA And .toString()
I have an XML file containing nodes with CDATA content.
Some of it is price and postage and I want to add those two.
example:
<artwork_price><![CDATA[699.99]]></artwork_price>
<artwork_postage><![CDATA[14.50]]></artwork_postage>
I then try to add the two like this
newprice += .....firstChild.nodeValue.toString();
newprice += .....firstChild.nodeValue.toString();
but newprice is 699.9914.50 instead of 714.49. It doesn't add them up!
what am I doing wrong?
help
View Replies !
View Related
[F8]Parsing CData From An XML File...
I am trying to seperate CData that I find in my XML file, but I don't know what is the best way to do this is. I can find the node that contains the data and can trace it to the screen, but I only want certain pieces of the data. How do I seperate the data within the CData?
Specifically, I want the "img src" hyperlink(not the "width", "height", etc.) and the comments(if any) before the "img src" hyperlink.
XML file:
PHP Code:
<?xml version="1.0" encoding="utf-8" ?>
- <rss version="2.0">
- <channel>
<title>my blog</title>
<link>http://blogsite.com/blogs.php?show=1234</link>
- <item>
<title>another test</title>
- <description>
- <![CDATA[ This is yet another test. <img src="http://picture.jpg" width="160" height="120" alt="another test"/>]]>
</description>
<link>http://blogsite.com/blogs.php?show=1234</link>
<guid>http://blogsite.com/blogs.php?show=1234</guid>
<pubDate>Mon, 02 Apr 2007 05:52:53 +0100</pubDate>
</item>
- <item>
<title>image test</title>
- <description>
- <![CDATA[ <img src="http://image.jpg" width="158" height="160" alt="image test"/> ]]>
</description>
<link>http://blogsite.com/blogs.php?show=1234</link>
<guid>http://blogsite.com/blogs.php?show=1234</guid>
<pubDate>Mon, 02 Apr 2007 05:49:06 +0100</pubDate>
</item>
</channel>
</rss>
I have a loop and my switch/case catches the node that has the CData info:
PHP Code:
.
.
.
case "description":
trace(nodeNodeProperty.firstChild);
break;
The above prints all the CData so I know I have the right node. Thanks for the help.
View Replies !
View Related
|