# XML Parsing problems

**URL:** <https://forums.plex.tv/t/xml-parsing-problems/1746>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [May 12, 2009, 8:35pm UTC](https://forums.plex.tv/t/xml-parsing-problems/1746 "2009-05-12T20:35:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nba](https://avatars.discourse-cdn.com/v4/letter/n/85f322/32.png) [@nba](https://forums.plex.tv/u/nba)\
**Post date:** [May 12, 2009, 8:35pm UTC](https://forums.plex.tv/t/xml-parsing-problems/1746/1 "2009-05-12T20:35:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![elan](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/elan/32/5_2.png) [@elan](https://forums.plex.tv/u/elan)\
**Post date:** [May 12, 2009, 9:12pm UTC](https://forums.plex.tv/t/xml-parsing-problems/1746/2 "2009-05-12T21:12:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nba](https://avatars.discourse-cdn.com/v4/letter/n/85f322/32.png) [@nba](https://forums.plex.tv/u/nba)\
**Post date:** [May 12, 2009, 9:47pm UTC](https://forums.plex.tv/t/xml-parsing-problems/1746/3 "2009-05-12T21:47:31Z")

</div>

Yes! At last, it works 🙂 Thanks a bunch for the quick help!  
  
I also found another error, had video.xpath instead of feed.xpath

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 20, 2019, 8:26pm UTC](https://forums.plex.tv/t/xml-parsing-problems/1746/4 "2019-12-20T20:26:31Z")

</div>

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