XML Parsing problems

Having trouble parsing a tag with a namespace prefix
Hi

I am making a plugin for DR (Danish National TV), but I am having trouble parsing a rss feed xml tag with a namespace prefix.

This is my code:
[codebox]PLUGIN_NAMESPACE = {'itunes':'http://www.itunes.com/dtds/podcast-1.0.dtd'}
url = "http://vpodcast.dr.dk/feeds/deadline_2sektionrss.xml"
feed = XML.ElementFromURL(url, errors="ignore").xpath('//channel', namespaces=PLUGIN_NAMESPACE)[0]
desc = feed.find('description').text
#img = feed.find('itunes:image').get('href')
img = video.xpath('itunes:image', namespaces=PLUGIN_NAMESPACE)[0].get('href')
retInfo = (desc, img)[/codebox]

It is the itunes:image bit that is the troublemaker.
I tried looking at other plugin examples and googled how xpath works, but for no avail.
Any help would be greatly appreciated.

Hmm, you might want to try xpath(’//itunes:image’) as it seems to appear at the top level and not per item.

Yes! At last, it works :slight_smile: Thanks a bunch for the quick help!

I also found another error, had video.xpath instead of feed.xpath

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.