# Xml news not working

**URL:** <https://forum.kirupa.com/t/xml-news-not-working/173924>\
**Category:** Uncategorized\
**Created:** [December 30, 2005, 10:01pm UTC](https://forum.kirupa.com/t/xml-news-not-working/173924 "2005-12-30T22:01:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nugget](https://avatars.discourse-cdn.com/v4/letter/n/ebca7d/32.png) [@nugget](https://forum.kirupa.com/u/nugget)\
**Post date:** [December 30, 2005, 10:01pm UTC](https://forum.kirupa.com/t/xml-news-not-working/173924/1 "2005-12-30T22:01:25Z")

</div>

can anyone help me out, im trying to make my own news class with xml and i can’t get it to work, all my text field says is “undefined”;

here is my code:

```auto
_global.News = function(xml_file, txt_holder) {
 this.xml_file = xml_file;
 this.text_holder = txt_holder;
 this.loadXML();
 this.Show(0);
};
N = News.prototype;
AsBroadcaster.initialize(N);
N.loadXML = function() {
 news_xml = new XML();
 news_xml.ignoreWhite = true;
 news_xml.onLoad = function(sucess) {
  (sucess) ? this.processXML(news_xml) : this.text_holder.text="Error reading xml, check later";
 };
 news_xml.load(this.xml_file);
};
N.processXML = function(news_xml) {
 news_xml.ignoreWhite = true;
 var d = news_xml.firstChild.childNodes;
 var output = new Array();
 for (var c = 0; c<d.length; c++) {
  output[c] = "<font color='#00ccff'>"+d[c].attributes.date+"</font> - <font color='#009966'>"+d[c].attributes.title+"</font><br>"+d[c].firstChild.nodeValue+"<br><br><br>";
 }
 this.news_array = output;
}
N.Show = function(n) {
 var lastIndex = this.news_array.length-1;
 if (n>lastIndex) n =0;
 else if (n<0) n=lastIndex;
 this.newIndex = n;
 this.text_holder.htmlText = this.news_array[n];
}
N.Next = function(){
 this.Show(this.newIndex+1);
}
N.Previous = function() {
 this.Show(this.newIndex-1);
}

```

and here is my xml:

```auto
 
<feed>
 <news date="12-27-05" title="webdesign">Site is finished</news>
 <news date="12-06-05" title="Home Improvements">Need Hurricane Shutters? </news>  
</feed>

```

and i called it like this - with two buttons, one up and one down  
where “nwes.xml” is my file and “\_root.news” is my dynamic text field.

```auto

my_news = new News("news.xml",_root.news);
up.onPress = function() {
 my_news.Next();
};
down.onPress = function() {
 my_news.Previous();
};

```

thanks
