Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your <code>print &gt;&gt;f</code> are after the <code>for</code> loop, so they are run once, and operate on the data that you last saved to <code>title</code>, <code>description</code>, and <code>str</code>.</p> <p>You should open the file before the <code>for</code> loop and then put the <code>print &gt;&gt;f</code> lines inside the loop.</p> <pre><code>import urllib import sys import xml.dom.minidom #The url of the feed address = 'http://www.vg.no/export/Alle/rdf.hbs?kat=nyheter' f = open('lawl.txt','w') #Our actual xml document document = xml.dom.minidom.parse(urllib.urlopen(address)) for item in document.getElementsByTagName('item'): title = item.getElementsByTagName('title')[0].firstChild.data link = item.getElementsByTagName('link')[0].firstChild.data description = item.getElementsByTagName('description')[0].firstChild.data str = link.strip("http://go.vg.no/cgi-bin/go.cgi/rssart/") print "\n" print "------------------------------------------------------------------" print '''"%s"\n\n%s\n\n(%s)''' % (title.encode('UTF8', 'replace'), description.encode('UTF8','replace'), str.encode('UTF8','replace')) print "------------------------------------------------------------------" print "\n" print &gt;&gt;f, "----------------------Nyeste paa VG-------------------------------" print &gt;&gt;f, title.encode('UTF8','replace') print &gt;&gt;f, description.encode('UTF8','replace') print &gt;&gt;f, str.encode('UTF8','replace') print &gt;&gt;f, "------------------------------------------------------------------" print &gt;&gt;f, "\n" </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload