|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Parsing News Feeds
This an actual XML file that I would like to parse with a Flash ActionScript from a news provider.
The file has always the same following structure except, as shown below, for the <news id="[color=royal blue]000000[/color]"> nodes which "[color=royal blue]id[/color]" value attribute change upon news update. --------------------------------- <?xml version="1.0" encoding="ISO-8859-1" ?> - <crawl> <datePublication>19/01/2004 12:13:33</datePublication> <br /> <category>Techno News</category> <dateMod year="2004" month="01" day="19" hour="12" minutes="13" /> <news id="[color=royal blue]141840">News sample bla bla bla</news> [/color] <br /> <category>Headlines</category> <dateMod year="2004" month="01" day="19" hour="12" minutes="04" /> <news id="[color=royal blue]147808">Other news sample bla bla bla</news> [/color] <br /> <category>Top News</category> <dateMod year="2004" month="01" day="19" hour="11" minutes="42" /> <news id="[color=royal blue]141830">Other news sample bla bla bla</news> [/color] <br /> <category>Local News</category> <dateMod year="2004" month="01" day="19" hour="11" minutes="41" /> <news id="[color=royal blue]187819">Other news sample bla bla bla</news> [/color] <br /> <category>World News</category> <dateMod year="2004" month="01" day="19" hour="11" minutes="38" /> <news id="[color=royal blue]147727">Other news sample bla bla bla</news> [/color] <br /> <category>Top News</category> <dateMod year="2004" month="01" day="19" hour="10" minutes="58" /> <news id="[color=royal blue]127801">Other news sample bla bla bla</news> [/color] <br /> - </crawl> ---------------------------------------- Yet, I did not find any Flash ActionScript to make a news ticker out of this XML file. The best I got is this: (But it only extract the last node succesfully, not all). ![]() gDoc = null; function GetNewData() { gDoc = new XML(); gDoc.onload = HandleXMLOnLoad; gDoc.load ("newsfile.xml"); } function HandleXMLOnLoad(success) { if (success) { debugXML = gDoc.toString(); var node = gDoc.firstChild.firstChild; while (node != null) { if (node.nodeName=="datePublication") wdatpub = node.firstChild.nodeValue; if (node.nodeName=="category") wCat = node.firstChild.nodeValue; if (node.nodeName=="news") wNews = node.firstChild.nodeValue; node = node.nextSibling; } scriptTimer.gotoAndPlay(2); } } //end ------------------- Any Idea? thks! |
|
#2
|
|||
|
|||
|
I don't know action script, but my guess is you need to handle whatever displaying you're going to do inside your while loop. Either that or make wdatpub, wCat and wNews some kind of array. The way you have it now after the while loop is finished your variables will only contain values from the last node.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Parsing News Feeds |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|