Flash 8 Pro/ActionScript 2.0
Well, you see, I’m trying to create what I’d like to call a “News Feed” in which data from the RSS/XML of CNN’s Topstories is put into a scrolling Dynamic Text Field. The Scrolling, I understand, but when I use the script:
[SIZE=1]newsfeed_xml.onLoad = function(success){[/SIZE]
[SIZE=1]if(success){[/SIZE]
[SIZE=1]trace(newsfeed_xml.firstChild.firstChild.nextSibling.nextSibling.nodeValue)[/SIZE]
[SIZE=1]}[/SIZE]
[SIZE=1]}[/SIZE]
This code will display the first "Description part of the XML. I’ll just copy/paste the beginning of the XML here:
[COLOR=silver]<?xml version=“1.0” encoding=“UTF-8”?>[/COLOR]
[COLOR=silver]<?xml-stylesheet href="[/COLOR][COLOR=silver]http://rss.cnn.com/~d/styles/rss2full.xsl[/COLOR][COLOR=silver]" type=“text/xsl” media=“screen”?><?xml-stylesheet href="[/COLOR][URL=“http://rss.cnn.com/~d/styles/itemcontent.css”][COLOR=silver]http://rss.cnn.com/~d/styles/itemcontent.css[/COLOR][COLOR=silver]" type=“text/css” media=“screen”?><rss xmlns:feedburner="[/COLOR][URL=“http://rssnamespace.org/feedburner/ext/1.0”][COLOR=silver]http://rssnamespace.org/feedburner/ext/1.0[/COLOR][COLOR=silver]" version=“2.0”>[/COLOR]
[COLOR=darkred]<channel>[/COLOR]
[COLOR=darkgreen]<title>CNN.com</title>[/COLOR]
[COLOR=darkgreen]<link>http://www.cnn.com/?eref=rss_topstories</link>[/COLOR]
[COLOR=darkgreen]<description>CNN.com delivers up-to-the-minute news and information on the latest top stories, weather, entertainment, politics and more.</description>[/COLOR]
[COLOR=dimgray]<language>en-us</language>[/COLOR]
[COLOR=dimgray]<copyright>© 2007 Cable News Network LP, LLLP.</copyright>[/COLOR]
[COLOR=dimgray]<pubDate>Wed, 30 May 2007 19:59:26 EDT</pubDate>[/COLOR]
[COLOR=black]I have highlighted what I believe, and what Kirupa seems to elude to is the “channel” is the “first” firstChild, “text” is the “channel’s” firstChild and Link/Description is “title”'s Siblings, which is why I put the amount of firstChild/nextSibling stuff into my code. Now I’m sure many of you are more experienced than I, so this is what I’m wondering:[/COLOR]
“When I tell it to trace, or display it in a dynamic text field, when I only type “rss.cnn.com/topstories.rss” (this may not be that actual link) it displays all the code (Good!). But once I throw some firstSibling’s in there, it faults out. The dynamic text/trace says undefined/null. What I found to be interesting, is that when I tell it just “childNodes” it displays all but the XML version garbage, but the entire code of the XML is there. But once I add any “relation” commands it tells me null/undefined. So, sorry for making you read all this, but I really would like a definitive and exact answer, here’s a few questions:”
- Do I have to some how make the XML cached so that it loads from my computer?
- What scripting am I doing wrong?
By the way, the script at top, that is NOT the entire script, it’s just the portion that must be the root of my problem. Also, I’d consider myself an Intermediate AS2.0’er, so I’m sure many of you Experts out there know far more than I. Keep in mind, it seems that the way I place my firstChild/nextSibling/childNodes may be the problem, and if you’d like to see the script for the XML, here it is. Yes, it is formatted, but you guys know, Right-Click then View Source, and you’ll come up with the XML file in Notepad. You knew that right?
All help on this IS Appreciated, and I thank you all very much,
Sup_Legolas