Parse XML in python



I am partway through pasing xml in python but have run into a bit of a stumbling block with the xml I am trying to render I am using xml.dom.minidom and I can get the xml no worries that bit is easy just the place I am getting it from is messing about with weird syntax what I am getting is something like this.



<enclosure name="link1" url="http://ift.tt/1psGQ0r" type="video/mp4" />


What I am strugling to do with the code bellow is get a way to extract the string from the url attribute I have googled and found nothing. I thought someone with more experience in xml would have an idea about how to do this. Bellow is the code I have so far for this section



files = urllib2.urlopen(x)
data = files.read()
files.close()

dom = parseString(data)

xmlTag = dom.getElementsByTagName('enclosure')[0].toxml()
print xmlTag

No comments:

Post a Comment