I'm trying to parse an xml url with minidom. I have an url with my xml data.
This is my code:
url = "http://myurl.com/wsname.asp" datasource = urllib2.urlopen(url) dom = parse(datasource) handleElements(dom)my handleElements function to parse xml:
def handleElements(dom): Elements = dom.getElementsByTagName("book") for item in Elements: getText(item.getElementsByTagName("id")[0].childNodes) ....My xml:
<html><head><style type="text/css"></style></head> <body> <bibliothque> <book> <id>747</id> <title>L'alchimiste</nomclient> <author>Paulo Cohelo </nomposte> </book> ... </bibliothque> </body>I get no error, but no result!
my
handleElements()works fine because when I copy the same data from my url put it in a string and useparseStringinstead ofparseeverything works fine and I get my results.But when trying to
openurl,Elements is empty and the loop is not even started
Seems that I need to get the sourcecode of the url (not it's content) (like the view-source in chrome) How can I do that?
Thanks