Python and XML

I am working on a photo plugin.



My RSS XML is structured like the following:



<item><br />
	  <title>Lightning Bolt. June 2006.</title><br />
	  <link>http://www.kylelamyphoto.com/gallery/2390052_crHBZ#106085683_AHvBT</link><br />
	 <br />
	  <media:group><br />
		<media:content url="placeholder" fileSize="13508" type="image/jpeg" medium="image" width="290" height="450"><br />
		  <media:hash algo="md5">a872bcac89630bea7c761d432357e640</media:hash><br />
		</media:content><br />
	  </media:group><br />
	  <media:keywords>lightning, weather, night, clouds, thunder, flash, strike, electricity, portfolio</media:keywords><br />
	  <media:copyright url="http://www.kylelamyphoto.com">kylelamyphoto</media:copyright><br />
	  <media:credit role="photographer">kylelamyphoto</media:credit><br />
</item>



Is there a way to access the XML tags that have a colon in python? I know I can do item.link in order to get the link attribute, but I really need to get inside the media:group and access the media:content attribute.

Thanks.

If you want to access with the XML parser, you’ll need to add a namespace definition and then you can use XPATH like …xpath(“media:content”)[0].get(‘url’). Check the Revision3 plug-in for an example, they access the media:content element.

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