Here’s my as
var news_xml = new XML();
news_xml.ignoreWhite = true;
news_xml.onLoad = function(success){
if (success) createNews(this);
else trace("Error loading XML file");
}
// load the xml
news_xml.load("news.xml");
function createNews(newsXML){
// start with the first item in the XML
var items = newsXML.firstChild.firstChild.childNodes;
for (var i=0; i<items.length; i++) {
var story = items*.firstChild; // same as items*.childNodes[0]
var date = items*.childNodes[1]; // second child node
news_txt.htmlText = date.nodeValue +"<br><br>"+ story.nodeValue;
trace(i);
}
}
And then my XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<news_story>
<entry>
<story>
<![CDATA[Here is the first news story.]]>
</story>
<date>1191124800</date>
</entry>
<entry>
<story>
<![CDATA[Another news posting.]]>
</story>
<date>1191038400</date>
</entry>
</news_story>
In my text area it shows only this:
undefined
1191124800
So the date value should be shown first (based on my code) but it’s shown second. And I guess what is suppose to be the story is shown as undefined. On top of that, it seems my loop isn’t going through all the items in the XML.