0

Is there a way to display the item description text for a flash as2 rss feed. My code is listed below. Although, it only displays the titles. Any help would be great.

stop();
xmlLoad = new XML();
xmlLoad.load("http://www.astrology.com/horoscopes/monthly-overview.rss");
xmlLoad.ignoreWhite = true;
xml_holder.html = true;
xmlLoad.onLoad = function(success){
//if successful
if(success && xmlLoad.status == 0){      
//reset the text
xml_text="";   
//list of items
var xmlItems:XML = xmlLoad.firstChild.firstChild;
for (var m = 0; m<xmlItems.childNodes.length; m++) {
 //grab each item
 if (xmlItems.childNodes[m].nodeName == "item") {
    for (var n = 0; n<xmlItems.childNodes[m].childNodes.length; n++) {
       if (xmlItems.childNodes[m].childNodes[n].nodeName == "link") {
          //grab the link of the item
          itemlink=xmlItems.childNodes[m].childNodes[n].firstChild.toString();   
       }
       if (xmlItems.childNodes[m].childNodes[n].nodeName == "title") {
          //grab the title of the item
          itemtitle=xmlItems.childNodes[m].childNodes[n].firstChild.toString();   
       }
    }
    //add the current item
    xml_text+= "<a href=\""+itemlink+"\">"+itemtitle+"</a><br><br>";
    }   
    }         
    }
    //set the text
    xml_holder.htmlText = xml_text;
    }

1 Answers1

0

You can get the description like you did for title and link. As description contains HTML in this feed, you need to access it with the nodeValue property.

I added a switch to test nodeNames and some vars declarations.

xmlLoad.onLoad = function(e) {
      var xmlItems:XMLNode = xmlLoad.firstChild.firstChild;
      var itemlink:String,itemtitle:String,itemdesc:String = '';

      for (var m:Number = 0; m<xmlItems.childNodes.length; m++) {
         if (xmlItems.childNodes[m].nodeName == "item") {
            var article:Array = xmlItems.childNodes[m].childNodes
            itemlink = itemtitle = itemdesc = '';
            for (var n:Number = 0; n<article.length; n++) {             
                switch (article[n].nodeName) {
                    case "link":
                        itemlink=article[n].firstChild.toString();  
                        break;
                    case "title":
                        itemtitle=article[n].firstChild.toString();  
                        break;  
                    case "description":
                        itemdesc=article[n].firstChild.nodeValue;  
                        break;
                }              
            }
            xml_text+= "<a href=\""+itemlink+"\"><u>"+itemtitle+"</u></a><br>" + itemdesc+ "<br><br>";
         }   
      }   

}   
RafH
  • 4,504
  • 2
  • 23
  • 23