Parse RSS feed -System.out

Hi,
As below i have been reading RSS feeds.
When i execute the parser.parse(url) method i get a dump of the xml bones from the feed onto System.out, which in my case is a catalina log file.
Is there any way/method that im not aware of that can prevent this going to System.out?
public void readRSSDocument() throws Exception {
        //Create the parser
        RssParser parser = RssParserFactory.createDefault();
        //Parse our url
        Rss rss = parser.parse(
                new URL("http://rss.cnn.com/rss/cnn_world.rss"));
    }output:
<rss>
<channel>
<title>
</title>
<link>
</link>
<description>
</description>
<language>
</language>
<copyright>
</copyright>
<pubDate>
</pubDate>
<ttl>
</ttl>
<image>
<title>
</title>
<link>
</link>
<url>
</url>
<width>
</width>
<height>
</height>
<description>
</description>
</image>
<atom10:link>
</atom10:link>
<atom10:link>
</atom10:link>
<item>
<title>
</title>
<guid>
</guid>
<link>
</link>
<description>
</description>
<pubDate>
</pubDate>
<feedburner:origLink>
</feedburner:origLink>
</item>
<item>
<title>
</title>
<guid>
</guid>
<link>
</link>
<description>
</description>
<pubDate>
..

I am presuming that you picked up the code from [this tutorial|http://java.sun.com/developer/technicalArticles/javaserverpages/rss_utilities/]
Looks like the library was compiled with System.out.println() statements in it.
There is always the handy little method "System.setOut()" to redirect it.
Alternatively, decompile the code, delete/comment the System.out.println statements and then recompile it.
Its not that hard. Here's the offending class:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name:   DocumentHandler.java
package com.sun.cnpi.rss.handlers;
import com.sun.cnpi.rss.elements.Element;
import com.sun.cnpi.rss.elements.Rss;
import java.io.PrintStream;
import java.util.*;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
// Referenced classes of package com.sun.cnpi.rss.handlers:
//            NullElementHandler, ElementHandler, HandlerException
public class DocumentHandler extends DefaultHandler
    public DocumentHandler()
        handlers = new HashMap();
        handlerStack = new Stack();
        parentStack = new Stack();
        rss = new Rss("rss");
        handlers.put(null, new NullElementHandler());
        parentStack.add(rss);
    public void registerHandler(String key, ElementHandler handler)
        handlers.put(key.toLowerCase(), handler);
    public void addToParentStack(Element parent)
        parentStack.add(parent);
    public Element popFromParentStack()
        return (Element)parentStack.pop();
    public Element peekParentStack()
        return (Element)parentStack.peek();
    public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException
        //System.out.println("<" + qName + ">");
        try
            ElementHandler currentHandler = (ElementHandler)handlers.get(qName.toLowerCase());
            handlerStack.add(currentHandler);
            if(currentHandler != null)
                Element parent = (Element)parentStack.peek();
                currentHandler.startElement(this, parent, uri, localName, qName, attributes);
        catch(HandlerException e)
            e.printStackTrace();
        super.startElement(uri, localName, qName, attributes);
    public void characters(char ch[], int start, int length)
        throws SAXException
        StringBuffer buffer = new StringBuffer();
        Element element = (Element)parentStack.peek();
        if(element.getText() != null)
            buffer.append(element.getText());
        buffer.append(ch, start, length);
        element.setText(buffer.toString());
        super.characters(ch, start, length);
    public void endElement(String uri, String localName, String qName)
        throws SAXException
        //System.out.println("</" + qName + ">");
        if(!handlerStack.isEmpty())
            try
                ElementHandler currentHandler = (ElementHandler)handlerStack.pop();
                if(currentHandler != null)
                    Element parent = (Element)parentStack.peek();
                    currentHandler.endElement(this, parent, uri, localName, qName);
            catch(HandlerException e)
                e.printStackTrace();
        super.endElement(uri, localName, qName);
    public Rss getRss()
        return rss;
    private Map handlers;
    private Stack handlerStack;
    private Stack parentStack;
    private Rss rss;
}

Similar Messages

  • How to parse RSS Feed - Different URL for each button

    I'm making an app with AS3 and I want to be able to load a different RSS Feed when the user clicks on each button. This is the code I have so far, has anyone any idea how I can modify my code to do this?
    here's my code so far:
    //IMPORT CLASSES
    import fl.controls.List;
    import flash.net.URLLoader;
    import flash.events.Event;
    import flash.net.URLRequest;
    cGOSSIP.addEventListener(MouseEvent.CLICK, doClick);
    function doClick (e:MouseEvent):void
    cGOSSIP.gotoAndStop ("GOSSIP"); 
    wNEWS.addEventListener(MouseEvent.CLICK, doClick2);
    function doClick2 (e: MouseEvent):void
              wNEWS.gotoAndStop ("WORLD NEWS");
    eNEWS.addEventListener(MouseEvent.CLICK, doClick3);
    function doClick3 (e: MouseEvent):void
              eNEWS.gotoAndStop ("ENT NEWS");
    fbNEWS.addEventListener(MouseEvent.CLICK, doClick4);
    function doClick4 (e: MouseEvent):void
              fbNEWS.gotoAndStop ("FB NEWS");
    //NEWSLIST FORMATTING
    var newsListTf:TextFormat = new TextFormat();
    newsListTf.font = "Verdana";
    newsListTf.color = 0xFFFFFF;
    newsListTf.size = 18;
    newsListTf.align = "left";
    newsList.setRendererStyle("textFormat", newsListTf);
    newsList.rowHeight = 100;
    newsList.allowMultipleSelection = false;
    //newsList.wordWrap = true;
    //NEWSDISPLAY TEXT AREA FORMATTING
    var rssStoryTf:TextFormat = new TextFormat();
    rssStoryTf.font = "Verdana";
    rssStoryTf.color = 0x6699CC;
    rssStoryTf.size = 22;
    rssStoryTf.align = "left";
    rssStory.setStyle("textFormat", rssStoryTf);
    //READMORE BUTTON FORMATTING
    var buttonTf:TextFormat = new TextFormat();
    buttonTf.font = "Verdana";
    buttonTf.color = 0xFFFFFF;
    buttonTf.size = 22;
    btn_ReadMore.setStyle("textFormat", buttonTf);
    //RSS FEED
    var rssLoader:URLLoader = new URLLoader();
    var rssURL:URLRequest = new URLRequest
    ("http://rssfeeds.tv.adobe.com/adobe-higher-education-solutions.xml");
    rssLoader.addEventListener(Event.COMPLETE, rssLoaded);
    newsList.addEventListener(Event.CHANGE, selectRssStory);
    btn_ReadMore.addEventListener(MouseEvent.CLICK, goToURL);
    rssLoader.load(rssURL);
    var newsXML:XML = new XML();
    var currentStoryURL:URLRequest = new URLRequest();
    newsXML.ignoreWhitespace = true;
    function rssLoaded(evt:Event):void
    newsXML = new XML(rssLoader.data);
    //trace(newsXML);
    for(var item:String in newsXML.channel.item) {
    //newsList.addItem({label: newsXML.channel.item[item].pubDate.substr(0, 16)
    //+": " + newsXML.channel.item[item].title } );
    newsList.addItem({label: newsXML.channel.item[item].title.substr(0, 40)
    +" ..." } );
    newsList.selectedIndex = 0;
    //FIRST LOAD
    currentStoryURL = new URLRequest(newsXML.channel.item[0].link);
    rssStory.htmlText = newsXML.channel.item[0].description;
    function selectRssStory(evt:Event):void
    rssStory.htmlText = newsXML.channel.item[evt.target.selectedIndex ].description;
    currentStoryURL = new URLRequest(newsXML.channel.item[evt.target.selectedIndex
    ].link);
    function goToURL(event:MouseEvent):void
    navigateToURL(currentStoryURL);

    I copied the wrong code, it works and loads the feed but I have a number of buttons in the main menu and I want to be able to load a different rss feed for each button?
    Here's the code.
    btn_Home.addEventListener(MouseEvent.CLICK, clickHome);
    function clickHome(e:MouseEvent):void
              gotoAndStop ("START");
    //NEWSLIST FORMATTING
    var newsListTf:TextFormat = new TextFormat();
    newsListTf.font = "Verdana";
    newsListTf.color = 339999;
    newsListTf.size = 18;
    newsListTf.align = "left";
    newsList.setRendererStyle("textFormat", newsListTf);
    newsList.rowHeight = 100;
    newsList.allowMultipleSelection = false;
    //newsList.wordWrap = true;
    //NEWSDISPLAY TEXT AREA FORMATTING
    var rssStoryTf:TextFormat = new TextFormat();
    rssStoryTf.font = "Verdana";
    rssStoryTf.color = 0x6699CC;
    rssStoryTf.size = 22;
    rssStoryTf.align = "left";
    rssStory.setStyle("textFormat", rssStoryTf);
    //READMORE BUTTON FORMATTING
    var buttonTf:TextFormat = new TextFormat();
    buttonTf.font = "Verdana";
    buttonTf.color = 0xFFFFFF;
    buttonTf.size = 22
    btn_ReadMore.setStyle("textFormat", buttonTf);
    //RSS FEED
    var rssLoader:URLLoader = new URLLoader();
    var rssURL:URLRequest = new URLRequest
    ("http://www.tmz.com/rss.xml");
    rssLoader.addEventListener(Event.COMPLETE, rssLoaded);
    newsList.addEventListener(Event.CHANGE, selectRssStory);
    btn_ReadMore.addEventListener(MouseEvent.CLICK, goToURL);
    rssLoader.load(rssURL);
    var newsXML:XML = new XML();
    var currentStoryURL:URLRequest = new URLRequest();
    newsXML.ignoreWhitespace = true;
    function rssLoaded(evt:Event):void
    newsXML = new XML(rssLoader.data);
    //trace(newsXML);
    for(var item:String in newsXML.channel.item) {
    //newsList.addItem({label: newsXML.channel.item[item].pubDate.substr(0, 16)
    //+": " + newsXML.channel.item[item].title } );
    newsList.addItem({label: newsXML.channel.item[item].title.substr(0, 40)
    +" ..." } );
    newsList.selectedIndex = 0;
    //FIRST LOAD
    currentStoryURL = new URLRequest(newsXML.channel.item[0].link);
    rssStory.htmlText = newsXML.channel.item[0].description;
    function selectRssStory(evt:Event):void
    rssStory.htmlText = newsXML.channel.item[evt.target.selectedIndex ].description;
    currentStoryURL = new URLRequest(newsXML.channel.item[evt.target.selectedIndex
    ].link);
    function goToURL(event:MouseEvent):void
    navigateToURL(currentStoryURL);

  • "My iTunes" RSS Feed is out of order

    http://www.apple.com/itunes/myitunes/ says that the feed and widget is supposed to show my recent purchases. When I hook it up, it ends up showing stuff I bought last year, and not what I've bought in the past week!
    Does anybody else have their feed working, or is it broken for everybody?

    My advice is to send in feedback to the Apple iTunes team. That is a cop out answer but you have sent the e-mail to the wrong folks. If you send in a specific description of your problem to the feed back link you can be assured that it will get to the right people who will read it. Unfortunately, you will not get a response - but maybe we'll get a fix if enough people send in the form. Here's the link:
    *http://www.apple.com/feedback/itunesapp.html*

  • How can i implement informa to parse rss feed?

    is there any sample code or instructions?
    i am a beginer
    thanks a lot!

    it's not going to be simple unless you make your own ads.
    if you do not make your own, you must use someone else's ads.  if you use someone else's ads, you must use their api to include their ads to your game.

  • Rss:PubDate gives too much info to iWeb Blog RSS feed

    Hi All!
    Blog pages are setup in iWeb, and I've got an external "bot" that subscribes to the RSS feed from the blog. I'm grabbing the feed and stripping the {rss:pubDate}, {rss:title} and {rss:description} fields from the feed to re-format for posting in a discussion forum. (Note: no copyright issues here, as I write the blog, publish the feed, and host/admin/moderate the forum.)
    I'm wondering if the {rss:PubDate} field can be stripped down to include less information in the feed? It seems the PubDate is derived from the date and time of the blog post that's feeding it. ie: I enter 12/28/1993 in the blog entry "Date" field... the RSS feed comes out with the date I entered, AND the time of day and GMT offset the post was created. I don't need the time of day and GMT offset in my forum post headlines... is there any way to put less information into the {rss:PubDate} field via the blog entry page in iWeb? I'd like my {rss:PubDate} field to read "12/28/1993" instead of "12/28/1993 04:23:57 -0800"
    Ideas?
    -Case

    Bonjour
    For RSS feed, iWeb only use the URL you write in the Site Publishings settings. Make sure that you've written http://thesnugglycactus.net/ and not https://thesnugglycactus.net/
    But I don't really think that you wrote https, otherwise RSS feed would not be your only issue.

  • The RSS feed

    For some reason the AUR latest packages RSS feed is out of date.. on the site it looks fine but the rss2.php seems out of date.. is this a temporary problem? (the archlinux.org rss feed is fine though)

    oh.. im wondering if its possible to change this for someone who has access to the php? lol.. please?     

  • The system Pages library and its RSS feed do not work properly in SharePoint 2010

    This question is about RSS feed for the system 'Pages' library in SharePoint 2010.
    Now there are 5 'News' pages in the system 'Pages' library. In each news page there is one field called 'Title' for the news title. One of the news page is named 'FileNamePage5.aspx', and the news title is 'This is the title of page5'.
    I have enabled RSS in Site Settings, and configured RSS Settings for the 'Pages' library from the Communications section via Document Library Settings. I selected a few columns to display in the RSS description, including the 'Title' column. In the RSS feed
    (XML file) of the system 'Pages' library, I checked the XML source code, and found the news page file name appearing in the <title> tag below within the feed (XML source code).
     <title>FileNamePage5</title>
    and the original news title 'This is the title of page5' was appearing in the <description> tag in the feed (XML sorce code)
     <description><![CDATA[<div> ... This is the title of page5... </div>]]></description>.
    This would make it hard to extract ONLY the original news title (This is the title of page5) out of the feed via XSLT, because the data within the <description> tag in the feed also contains data from all other selected columns defined via the RSS
    Setting. If I did not select the 'Title' column via RSS Setting above, I even could not find the orinigal news title in the RSS feed.
    This is happening for all other news pages in the system 'Pages' library. Is this what SharePoint 2010 normally does? or is something wrong with the settings for site or the system 'Pages' library?
    How to display ONLY the original news title (This is the title of page5) in the <title> tag in the RSS feed. Please Help me to resolve this issue.
    谢亚军@Sydney

    Hi,
    According to your description, my understanding is that you want to display the value in Title column of Pages library in title tag in RSS Feed in SharePoint.
    I tested the same scenario per your post, the title tag in RSS Feed displayed the value of Name column in libraries and displayed the value of Title column in lists.
    It is by design and there is no OOB way to change the default column mapping in RSS Feed.
    I recommend to customize your own RSS Feed style sheet to make the title displays the value of Title column in SharePoint libraries.
    Here is a link about customizing the RSS Feed for document library for you to take a look:
    http://markeev.com/Articles/sharepoint-blog-rss.aspx
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Lenovo System Update and Lenovo Support RSS Feed (X60)

    Okay. I got Lenovo System Update (version 5, for Windows 7) and it did not offer me any Critical updates. Only Recommended and Optional ones. If it ain't broke, don't fix it, so I don't want to install Recommended and Optional updates, only the Critical ones if there is any.
    On the other hand I also have the Lenovo Support RSS Feed. But they bring me to dead links. For my X60 the two drivers in my RSS Feed are
    ThinkVantage Access Connections patch for Access Connections Version 5.95 for Windows 7 (32-bit, 64-...
    Patch module for Power Manager for Windows 7 (32-bit, 64-bit), Vista (32-bit, 64-bit) - ThinkPad -
    Both are totally dead links.
    The tricky part is that there is absolutely no correlation between the two: totally different drivers in the System Update and the RSS Feed.

    Hello both,
    SU has been discontinued because old SU version wouldn´t work with SP2.
    Refer to this thread in at the ThinkVantage board regarding this situation and possible solutions
    and ask your questions there, please.
    Thread locked.
    Follow @LenovoForums on Twitter! Try the forum search, before first posting: Forum Search Option
    Please insert your type, model (not S/N) number and used OS in your posts.
    I´m a volunteer here using New X1 Carbon, ThinkPad Yoga, Yoga 11s, Yoga 13, T430s,T510, X220t, IdeaCentre B540.
    TIP: If your computer runs satisfactorily now, it may not be necessary to update the system.
     English Community       Deutsche Community       Comunidad en Español

  • When I downloaded the new Mavericks system, all of the many RSS feeds I had in my mail app deleted. How do I get these back?

    When I downloaded the new Mavericks system, all of the many RSS feeds I had in my mail app deleted. How do I get these back?

    You can redownload most iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store        

  • RSS feed out of date

    I'd appreciated if you help me find a solution for an issue related to RSS. I have RSS HTML Widgets on my following pages, created with iWeb app:
    http://www.spanishonlyspanish.com/English/Home.html
    http://www.spanishonlyspanish.com/Spanish/Inicio.html
    http://www.spanishonlyspanish.com/Spanish/Podcast.html
    The feed source is my own page (also for iTunes):
    http://www.spanishonlyspanish.com/English/Podcast/rss.xml
    The problem is that the feed is not showing my last episode. In other words the feed is valid since it shows up on the pages cited above, but is out of date, because is not showing the last entry. It happened with my previous episode (31). After some hours the feed updated spontaneously, including the episode 31. But, again when I published the episode 32, it appeared in iTunes Store, on my Podcast page, but not on the pages where I created the RSS Widgets. I have checked the xml files on my FTP and they seem to be up to date.
    For uploading the new files I used the synchronizing feature of Transmit. Is the out of date RSS issue related to how I publish? Should I publish the whole site, for avoiding the break of the RSS, instead of just synchronizing?
    Please help
    Thanks
    Hernando Murillo
    PD: the podcast page is http://www.spanishonlyspanish.com/English/Podcast/Podcast.html

    Thanks Old Toad, but that didn't work in my case (RSS Feed not updating).
    My iWeb page http://web.me.com/eburrowes/EdinaLiberia/Projects/Projects.html
    still shows the feed on the day the widget was created, not the feed as it reads today -
    feed://www.irinnews.org/RSS/Liberia.xml
    Any pointers would be appreciated.

  • RSS Feed Lessons seem to be out of order.

    The lessons in the RSS Feed of the Day 1 lessons appear to be out of order.
    The second lesson in the RSS Feed describes how to apply scroll bars to a container.

    Hi, I was having a simliar problem after updating to Windows 10 and it was really annoying me. I seemed to have fixed it by changing some settings in the compatibility section of the application properties. Here's how I did it:Right-click skype and go to properties. Click on the 'Compatibility' tab. Check the 'Disable display scaling on high DPI settings'. Click 'Apply' and you're good to go! Hope this helps, Dan.

  • I figured out the XML RSS feed to webpage but..

    Hello All
    I finally figured out how to get and rss feed xml to my
    webpage(s) via the Spry xml data set etc.. when I previewed in IE
    it was fine but I uploaded it and I get an error
    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct
    the error and then click the Refresh button, or try again later.
    Only one top level element is allowed in an XML document.
    Error processing resource '
    http://www.michaelsondesign.com/Spry/r...
    I just want to show my boss that I have been working on this
    and would love to show him an example of this awesome technology is
    there something Im not uploading? What does this error mean?
    Thank you
    Rob

    Hi,
    I am trying to display an RSS feed on my website as well. I
    haven't figured it out.
    Can you help?
    Thanks,
    H.J.D.
    [email protected]

  • Blogger RSS feed parser tool

    Hello everyone,
    Is there any j2ee RSS parsing Utility for reading Blogger feeds? The one I could find in the site
    http://java.sun.com/developer/technicalArticles/javaserverpages/rss_utilities/
    is not parsing all the blogger feed elements. The tld has just a few element tags such as title, url, buildDate. I want to parse all the elements available in blogger feeds. The list of available rss feed elements for blogger is here:
    http://help.blogger.com/bin/answer.py?hl=en&answer=47270
    Thanks

    you can use a double dot ( .. ) to jump anywhere in your xml.  for example,
    myXm..link[4]
    should reference <link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/990363500266599125/posts/default?start-in dex=26&max-results=25"/>

  • When I try to read my rss-feed through yandex service, the browser and the whole system freeze for a significant amount of time. This started with Firefor 5 and is very unpleasant. Thank you in advance.

    When I try to download (and especially renew) a page with my rss-feed that I read with Yandex service, the browser freezes, and then the whole system freezes. It typically takes about 5-7 minutes to load a very minimalistic page, and I can't use my browser or my system during that time.
    This started with the release of Firefox 5. I use it on Ubuntu. I haven't experienced similar problems with any other websites.
    I have already contacted the Yandex team about the matter.
    I guess it's just a little weird that one of the Yandex services won't work in Firefox, as Firefox comes with a built-in yandex-bar in many cases. And it sure is frustrating.
    Thank you very much and I am looking forward to your reply.

    Firefox Hangs
    https://support.mozilla.com/en-US/kb/Firefox%20hangs
    Check and tell if its working.

  • How do you import RSS feeds into FF? (i have exported OPML file out of IE8 but can't find import option for feeds in FF)

    how do you import RSS feeds into FF? i have exported opml file out of IE8 but can't find how to import this into FF?

    See OPML Support: https://addons.mozilla.org/firefox/addon/2625

Maybe you are looking for