Welcome Guest ( Log In | Register )

3 Pages V   1 2 3 >  
Reply to this topicStart new topic
> Rss 2 File Reader
cybernetix
post Oct 14 2004, 06:11 PM
Post #1


ReloadeD
Group Icon
Group: Honored
Posts: 562
Joined: 20-May 04
From: Belgrade, Serbia
Member No.: 17





RSS 2 file reader



CODE
onload() { // cybernetix 13dots.com

    //  news source file
    sourcefile = "rss2_news.xml";

    // this one will search all nodes, if parameter direction is true
    // it will step forward, otherwise it wil step back 1 node
    //
    /* it is fast as a devil by himself, maybe even faster;) */
    XMLNode.prototype.goNextNode=function(direction) {
            if (direction) { // if true step forward 1 node
  // bingo, first one has content, thats what we are looking for
                if (this.firstChild!=null) return this.firstChild;
                var nodVal=this;
                // search next
                while (nodVal.nextSibling==null) {
                       // no further nodes, brake and return null
                       if (!nodVal.parentNode) return null;
                       nodVal=nodVal.parentNode; // found something
                }
                // return this one, it has something in it
                return nodVal.nextSibling;
             }
             else { // if false step back 1 node
                // in this example we don't need this one, but you can use it
                // for all xmls reading
                // no previous, return this one again
                if (!this.previousSibling) return this.parentNode;
                var nodVal=this.previousSibling;
                // search previous node
                while (nodVal.lastChild) {
                       nodVal=nodVal.lastChild;
                }
                // return this one
                return nodVal;                
             }  
    };
            
    // create xml object
    xmlNews=new XML();
    // load file
    xmlNews.load(sourcefile);
    xmlNews.ignoreWhite=true; // must be true
    xmlNews.onload=function(success) { // load
       if (success) { // file is there, ok
           // make copy of original, this is not neccessary, but it is handy, you can
           // later just change name of object xmlNews
           var xNode=xmlNews;
               // this is dynamic text filed which will receive text
        // NOTE: must be with HTML rendering option!
               _root._rssText.text="";
               // initiate vars
               var lastNodeName="", lastPermaLink=false, channelString="";
               // ok, lets go
               while (xNode.goNextNode(true)) {
                    xNode=xNode.goNextNode(true);
                    if (xNode.nodeName=="rss") {
                        // channel mode
                        channelString+="<b>"+xNode.nodeName+": "+xNode.attributes.version+"</b><br>";
                    } else if (xNode.nodeName=="channel") {
                        // just channel
                        channelString+="<u><b>"+xNode.nodeName+"</b></u><br><br>";
                    } else if (xNode.nodeName=="item") {
                        // we are in news section, define newsString, couse until it is not defined
                        // we are reading channel info
                        if (newsString==undefined) var newsString="";
                        newsString+="\n";
                    } else if (xNode.nodeName!=null) {
                        // node names
                        if (newsString==undefined) { // if we are still on channel info, read node into channel string
                            channelString+="<b>"+xNode.nodeName.toUpperCase()+": "+"</b>";
                        } else { // we are in news section, read node into news string
                            newsString+="<b>"+xNode.nodeName.toUpperCase()+": "+"</b>";
                        }
                        lastNodeName=xNode.nodeName; // remember this one for later use
                        if (lastNodeName=="guid") { // if it is guid for permanent link
                        // there are a few options, lets see all of them
                            if (xNode.attributes.isPermaLink!=undefined) {
                                // isPermaLink is defined, just write it down
                                lastPermaLink=xNode.attributes.isPermaLink;
                            } else {
                                // isPermaLink not defined, means it is true
                                lastPermaLink="true";
                            }
                        } else {
                            // we are not on guid node, so we don't need this one
                            lastPermaLink="false";
                        }
                    } else if (xNode.nodeValue!=null) {
                        // node values
                        if (newsString==undefined) { // if we are still on channel info, read node into channel string
                            if (lastNodeName=="link") {
                                channelString+="<u><a href='"+xNode.nodeValue+"'  target='_blank'>"+"Transfer to page"+"</a></u><br>"+"\n";
                            } else {
                                channelString+=xNode.nodeValue+"\n";
                            }
                        } else { // we are in news section, read node into news string
                            if (lastNodeName=="link") { // it it is link write it down with html render
                                newsString+="<u><a href='"+xNode.nodeValue+"'  target='_blank'>"+"Transfer to page"+"</a></u><br>"+"\n";
                            } else if (lastNodeName=="guid") { // we are on guid
                                if (lastPermaLink=="true") { // we have a permanent link, write it down with html render
                                    newsString+="<u><a href='"+xNode.nodeValue+"'  target='_blank'>"+"Permanent link"+"</a></u><br>"+"\n";
                                } else { // there is no permanent link
                                    newsString+=xNode.nodeValue+"\n";
                                }
                            } else { // write down other nodes
                                newsString+=xNode.nodeValue+"\n";
                            }
                        }
                    }
              }
              // finished, lets see what the news are
              _root._rssText.text=channelString+"\n\n"+"<u><b>news section</b></u><br><br>"+newsString;        
       } else {
              // news source file not found
              javascript("alert('file not found: "+sourcefile+"')");
       }
    };
}


you can test it here


you can find source swi and xml files in download section here

beta version of RSS2 reader/feeder can be reviewed :: HERE ::
 
+Quote Post  Go to the top of the page
Voodoo
post Jun 4 2005, 08:46 AM
Post #2


New Member
Group Icon
Group: Member
Posts: 1
Joined: 4-June 05
Member No.: 4,476





Hey cybernetix,

This looks great! Would you by chance have the .swi file for your beta version?

If so, I'd be interested in it.

Thanks
 
+Quote Post  Go to the top of the page
q_flame
post Jun 6 2005, 12:18 PM
Post #3


New Member
Group Icon
Group: Member
Posts: 5
Joined: 17-March 05
Member No.: 2,750



GREAT tuts!

txs man!
 
+Quote Post  Go to the top of the page
cybernetix
post Jun 7 2005, 03:20 PM
Post #4


ReloadeD
Group Icon
Group: Honored
Posts: 562
Joined: 20-May 04
From: Belgrade, Serbia
Member No.: 17





thanks guys hiya.gif



QUOTE
Would you by chance have the .swi file for your beta version?


I am sorry, but I am affraid I will not publish source code.
 
+Quote Post  Go to the top of the page
mobosof
post Jun 7 2005, 04:05 PM
Post #5


mister midnight
Group Icon
Group: Honored
Posts: 215
Joined: 7-September 04
Member No.: 653





dont know if this helps?
gregs post..newsfeeds

greg's post at swishtalk...putting newsfeeds on your site

http://www.mobosof.com/examples/newsfeed/newsFeed.html

from gsb's post



http://www.swishtalk.com/showthread.php?t=35983
 
+Quote Post  Go to the top of the page
*D*
post Jun 7 2005, 05:09 PM
Post #6


Merry KissMoose
Group Icon
Group: Main Team
Posts: 15,990
Joined: 18-May 04
From: North Pole
Member No.: 2





Will if thats the same, looks the same to me we have it here too smile.gif

Sat there for a year

http://www.13dots.com/forum/index.php?showtopic=234
 
+Quote Post  Go to the top of the page
mobosof
post Jun 8 2005, 01:48 AM
Post #7


mister midnight
Group Icon
Group: Honored
Posts: 215
Joined: 7-September 04
Member No.: 653





dont know blossom? bigwink.gif
saw a thread from swishtalk and Gregs reply..recently?
saw the request for help here so just pointed to it...apologies, i usually search 99.9% of everything too lolol..slaps wrist long distance if it is...slaps it anyway..should have checked
 
+Quote Post  Go to the top of the page
ashtondylan
post Jul 7 2005, 10:31 PM
Post #8


Banned - Posting Keygens
*
Group: Banned
Posts: 1
Joined: 7-July 05
Member No.: 5,276





Hi cybernetix

How can we get your beta version of RSS2 reader.

Is it posible for you to post the SWI of that.


Best Regards
 
+Quote Post  Go to the top of the page
cabeschristopher
post Jul 9 2005, 09:54 PM
Post #9


Regular Dot
Group Icon
Group: Member
Posts: 86
Joined: 10-May 05
Member No.: 3,904





Thats Awesome!! Just what I was looking for. Thanks a ton!!
 
+Quote Post  Go to the top of the page
*D*
post Jul 14 2005, 01:38 PM
Post #10


Merry KissMoose
Group Icon
Group: Main Team
Posts: 15,990
Joined: 18-May 04
From: North Pole
Member No.: 2





url's repaired for those unable to see a working version of this.
 
+Quote Post  Go to the top of the page

3 Pages V   1 2 3 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 29th July 2010 - 10:59 PM
High Paying Adsense List | Package Holidays | WoW Gold | Free Animated Greetings | Home Insurance