XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 19th, 2004, 02:11 PM
jessenco jessenco is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 3 jessenco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!

Reply With Quote
  #2  
Old January 21st, 2004, 02:13 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Parsing News Feeds


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT