Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6911047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:54:03+00:00 2026-05-27T08:54:03+00:00

I am still a python beginner. As a practice project I want to code

  • 0

I am still a python beginner. As a practice project I want to code my own RSS reader.
I found a helpful tutorial here: learning python. I used the code provided in that tutorial:

#! /usr/bin/env python    
import urllib2
from xml.dom import minidom, Node

""" Get the XML """
url_info = urllib2.urlopen('http://rss.slashdot.org/Slashdot/slashdot')

if (url_info):
    """ We have the RSS XML lets try to parse it up """
    xmldoc = minidom.parse(url_info)
    if (xmldoc):
        """We have the Doc, get the root node"""
        rootNode = xmldoc.documentElement
        """ Iterate the child nodes """
        for node in rootNode.childNodes:
            """ We only care about "item" entries"""
            if (node.nodeName == "item"):
                """ Now iterate through all of the <item>'s children """
                for item_node in node.childNodes:
                    if (item_node.nodeName == "title"):
                        """ Loop through the title Text nodes to get
                        the actual title"""
                        title = ""
                        for text_node in item_node.childNodes:
                            if (text_node.nodeType == node.TEXT_NODE):
                                title += text_node.nodeValue
                        """ Now print the title if we have one """
                        if (len(title)>0):
                            print title

                    if (item_node.nodeName == "description"):
                        """ Loop through the description Text nodes to get
                        the actual description"""
                        description = ""
                        for text_node in item_node.childNodes:
                            if (text_node.nodeType == node.TEXT_NODE):
                                description += text_node.nodeValue
                        """ Now print the title if we have one.
                        Add a blank with \n so that it looks better """
                        if (len(description)>0):
                            print description + "\n"
    else:
        print "Error getting XML document!"
else:
    print "Error! Getting URL"<code>

Everything works as expected and first I thought understood it all. But as soon as I use another RSS feed (e.g. “http://www.spiegel.de/schlagzeilen/tops/index.rss&#8221; I get a “terminated” error for my application from Eclipse IDE. Can’t say more about that error message since I can’t figure out where exactly and why the app terminates. The debugger doesn’t help much since it ignores my breakpoints. Well, that’s another issue.

Anybody got an idea what I am doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:54:04+00:00Added an answer on May 27, 2026 at 8:54 am

    Well the “terminated” message is not an error, it’s just for information that python has exited without error.

    You’re not doing anything wrong, it’s just that this RSS reader is not very flexible since it only knows one variant of RSS.

    If you compare the XML-Documents of slashdot and Spiegel Online you see differences in the structure of the documents:

    Slashdot:

    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ...>
      <channel rdf:about="http://slashdot.org/">
        <title>Slashdot</title>
        <!-- more stuff (but no <item>-tags) -->
      </channel>
      <item rdf:about="blabla">
        <title>The Condescending UI</title>
        <!-- item data -->
      </item>
      <!-- more <item>-tags -->
    </rdf:RDF>
    

    Spiegel online:

    <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
    <rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
      <channel>
        <title>SPIEGEL ONLINE - Schlagzeilen</title>
        <link>http://www.spiegel.de</link>
        <item>
          <title>Streit über EU-Veto: Vize Clegg meutert gegen britischen Premier Cameron</title>
        </item>
        <!-- more <item>-tags -->
      <channel>
    </rss>
    

    In the feed of Spiegel Online all <item> elements are in the <channel>-tag but in the slashdot feed they are in the root-tag (<rdf:RDF>). And your python-code expects the items only in the root-tag.

    If you want your rss reader to work for both feeds, you could for example change the following line:

    for node in rootNode.childNodes:
    

    To that:

    for node in rootNode.getElementsByTagName('item'):
    

    With that all <item>-tags are enumerated, regardless of where they are in the XML document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am still learning Python and as a little Project I wrote a script
Python beginner here. I've looked around and found similar questions but can't quite cobble
The import function of Python still confuses me sometimes. Here's an example: My project
im currently learning python (in the very begining), so I still have some doubts
Still learning Objective-C / iPhone SDK here. I think I know why this wasn't
I'm still a beginner to Python, so I thought I could as well learn
What's the ideal Python version for a beginner to start learning Python? I need
I'm still learning Python, and I'd love to know a way to make the
I'm still learning python. I just wrote this method to determine if a player
I'm still learning python and after playing around with pygame I noticed I'm re-importing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.