My code only seems to be accessing the 1st item in the RSS feed and not going on to the rest of the feed.
Any ideas?
#import library to do http requests:
import urllib2
#import pyserial Library
import serial
#import time library for delays
import time
#import xml parser called minidom:
from xml.dom.minidom import parseString
#Initialize the serial connection in com3
ser = serial.Serial("\\.\COM3", 9600)
i = 1
time.sleep(5)
while i == 1:
#download the rss file to use
file = urllib2.urlopen('http://feeds.bbci.co.uk/sport/0/football/rss.xml?edition=uk')
#convert to string
data = file.read()
#close the file
file.close()
#parse the xml from the string
dom = parseString(data)
#retrieve the first xml tag (<tag>data</tag>) that the
xmlTag = dom.getElementsByTagName('title')[2].toxml()
# the [2] indicates the 3rd title tag it finds will be parsed
# strip off the tag (<tag>data</tag> --> data)
xmlData = xmlTag.replace('<title>',"").replace('</title>',"")
#write the market ~ to serial
ser.write(str('~'))
time.sleep(5)
#split the string into individual words
nums = xmlData.split(' ')
#loop until all words have been printed
for num in nums:
ser.write(str(num))
ser.write(str(' '))
time.sleep(2)
ser.write(str('~'))
time.sleep(5)
Many Thanks