My brain has melted at this point, so I’ll ask you all - how do I filter for the following attribute:
story.attributes.year == “2005”
in the code below, so that only the nodes marked “2005” are displayed? Files are attached.
//Create textfield
this.createTextField("content_txt", 10, 0, 0, 390, 0);
//Create and load styles
var pressStyle:TextField.StyleSheet = new TextField.StyleSheet();
pressStyle.load("news.css");
content_txt.styleSheet = pressStyle;
//Textfield attributes
content_txt.multiline= true;
content_txt.wordWrap = true;
content_txt.html = true;
content_txt.autoSize = true;
content_txt.variable = "press";
// The first step is to activate the XML object
newsXML = new XML();
newsXML.onLoad = pressLoad;
newsXML.load("newsPress.xml");
function pressLoad(OK) {
if (OK == true) {
Publish(this.firstChild);
//content_txt.htmlText = newsXML;
}
}
function Publish(HeadlineXMLNode) {
if (HeadlineXMLNode.nodeName.toUpperCase() == "BROADCAST") {
press = ""; // Removes "undefined" instance
story = HeadlineXMLNode.firstChild;
while (story != null) {
if (story.attributes.year == "2005") { trace("2005"); }
if (story.nodeName.toUpperCase() == "STORY") {
lead = "";
body = "";
URL = "";
element = story.firstChild;
while (element != null) {
if (element.nodeName.toUpperCase() == "LEAD") {
lead = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "BODY") {
body = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "URL") {
URL = element.firstChild.nodeValue;
}
element = element.nextSibling;
}
press += "<font family='Verdana' size='11' color='#B2B2B2'>"+lead+"</font><br>";
}
story = story.nextSibling;
}
}
}