I’m trying to display an xml file (news.xml) in a text field (with an instance name of newsTxt). The data displays exactly as I want it to when I trace it, but when I try to load it into the text field, it only shows the last section of the xml file… just says “post number 3”
Here’s the xml file:
<?xml version="1.0" encoding="utf-8"?>
<news>
<post>
<date>01.07.11</date>
<content>A lot has changed for the band. For one, we are no longer Tracey Bones. Now we are called Sinister Kid. Also, the band's added a new member to its ranks -- me, Andres, on vocals, which leaves Tyler able to concetrate completely on guitar. And I brought this website with me. It's not much in terms of content, but I figured I'd get a little creative with the animation, so enjoy.</content>
</post>
<post>
<date>01.07.11</date>
<content>post number 2</content>
</post>
<post>
<date>01.07.11</date>
<content>post number 3</content>
</post>
</news>
…and here’s the actionscript I am using:
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
{
var xml:XML = XML(xmlLoader.data);
var newsChildren:XMLList = xml.post.children();
for each (var newsInfo:XML in newsChildren)
{
newsTxt.text = newsInfo;
}
}
What am I doing wrong?