News feed, xml with a bit of CSS added

Hi,

I’m currently trying to make a news feed, and in order to do that, I need a little help. I’ve been combining XML and CSS for a while now, but every time, I try making something useful with it, the XML stops me. Now, I’m not a hawk to XML actionScripting, but the idea of the feed is, to pull some lines from an xml document into my news textbox, and then add a CSS style to it. And then for the user to swich between the different news, by hitting the “left” or “right” key.

Everything works, except the swich function, so that the user will be able to read more than just the first news child.

This is my AS:
[AS]// xml & style
var myStyle:TextField.StyleSheet = new TextField.StyleSheet();
var myXML:XML = new XML();
// styleSheet
myStyle.load(“CSS.css”);
myStyle.onLoad = function(success) {
if (success) {
nyheder.styleSheet = this;
load_xml();
}
};
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevNyhed();
} else if (Key.getCode() == Key.RIGHT) {
nextNyhed();
}
};
Key.addListener(listen);
// XML load
function load_xml() {
myXML.ignoreWhite = true;
myXML.load(“forside.xml”);
myXML.onLoad = function(success) {
p = 0;
mainNode = this.firstChild.childNodes[p];
var nyhederOverskrift:Array = new Array();
nyhederOverskrift = mainNode.childNodes[0].childNodes;
for (var i = 0; i<nyhederOverskrift.length; i++) {
var nyhederOverskriftVar = nyhederOverskrift*.toString();
var nyhederDato:Array = new Array();
nyhederDato = mainNode.childNodes[1].childNodes;
for (var i = 0; i<nyhederDato.length; i++) {
var nyhederDatoVar = nyhederDato*.toString();
var nyhederTekst:Array = new Array();
nyhederTekst = mainNode.childNodes[2].childNodes;
for (var i = 0; i<nyhederOverskrift.length; i++) {
var nyhederTekstVar = nyhederTekst*.toString();
var nyhederLink:Array = new Array();
nyhederLink = mainNode.childNodes[3].childNodes;
for (var i = 0; i<nyhederLink.length; i++) {
var nyhederLinkVar = nyhederLink*.toString();
nyheder.htmlText = “<span class=‘titel’>”+nyhederOverskriftVar+"</span><br><span class=‘dato’>"+nyhederDato+"</span><br><br><span class=‘tekst’>"+nyhederTekst+"</span><br><br><a href=’"+nyhederLink+"’ target=’_blank’>"+nyhederLink+"</a><br><span class=‘center’>· · · · · · · · · · · · · · · · · · · · · · · · · · · ·</span>";
}
}
}
}
};
}
function nextNyhed() {
if (p<(total-1)) {
p++;
}
}
function prevNyhed() {
if (p>0) {
p–;
}
}[/AS]

My XML looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<nyheder>
<news>
	 <header>News 1</header>
	 <date>29-05-05</date>
	 <text>Google just launched their new portal - still beta.</text>
	 <link>http://www.google.com/ig</link>
</news>
<news>
	 <overskrift>News 2</overskrift>
	 <dato>28-05-05</dato>
	 <tekst>This is working!</tekst>
	 <link>http://www.macro-design.org</link>
</news>
</nyheder>

Just so there aren’t any doubt, it all loads into my “nyheder” textbox, just fine, and the CSS is added. But I can’t make the swich funtion, so therefore I can only see the first news content, and not the following.

Any help, hint and/or trick, would be much appreciated, thanks :slight_smile: