Hi all. I’m importing an XML file with 3 elements into Flash CS3 (AS 3.0) and when I trace the results, I get everything in the XML file parsed nicely and cleanly. Now, I have a dynamic textfield that I set equal to the parsed results, instead of a trace, but when I do it, the textfield only outputs 1 node. I have the textfield set to multiline and it still only returns 1 node. Here is my xml file:
<?xml version="1.0" encoding="utf-8"?>
<news>
<heading date="02.15.09" title=" - NEW SITE">
<copy>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas euismod dui eget massa. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</copy>
</heading>
<heading date="02.06.09" title=" - SITE AMET">
<copy>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas euismod dui eget massa. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</copy>
</heading>
<heading date="01.21.09" title=" - MAECENAS">
<copy>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas euismod dui eget massa. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</copy>
</heading>
</news>
And here is my ActionScript:
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, loadXML);
xmlLoader.load(new URLRequest("news.xml"));
function loadXML(e:Event):void {
xmlData = new XML(e.target.data);
parseNews(xmlData);
}
function parseNews(news:XML):void {
var newsHeadings:XMLList = news.heading;
for each(var headline:XML in newsHeadings)
{
news_txt.text = headline.attribute("date") + headline.attribute("title") + "
" + headline.copy.text() + "
";
}
}
I’d appreciate anything you can offer. Thanks so much.
Jesse