Re: [XML-SIG] parsing XML with minidom

2010-04-28 Thread kimmyaf
Thanks all for the help. This gives me alot of good options and I have a few working I learned a lot! kimmyaf wrote: > > Hello. I've only done a litte bit of parsing with minidom before but I'm > having trouble getting my values out of this xml. I need the latitude and > longitude values

Re: [XML-SIG] parsing XML with minidom

2010-04-27 Thread Stefan Behnel
kimmyaf, 27.04.2010 23:32: handler = urllib2.urlopen(url) xml_response = handler.read() handler.close() tree = ET.parse("GeocodeResponse.xml") >> Do I have to use a file? I tried to do >> >> tree = ET.parse(xml_response) parse() is meant for parsing files. Use fromstring()

Re: [XML-SIG] parsing XML with minidom

2010-04-27 Thread Fred Drake
On Tue, Apr 27, 2010 at 7:37 PM, Peter Bigot wrote: > Google is uninterested in defining schema for their APIs, so you need to > process the XML manually and hope they don't change their interface. And indeed, they do change their schemas without real concern backward compatibility. The sitemaps

Re: [XML-SIG] parsing XML with minidom

2010-04-27 Thread Peter Bigot
I'd have to concur with that recommendation. Google is uninterested in defining schema for their APIs, so you need to process the XML manually and hope they don't change their interface. BTW: The lat and lon components of the location are elements, not attributes. For minidom, use: lat = ite

Re: [XML-SIG] parsing XML with minidom

2010-04-27 Thread Luis Miguel Morillas
2010/4/27 kimmyaf : > > I don't really know... Here's the whole story. > > I am retrieving the xml by calling this link. > > http://maps.google.com/maps/api/geocode/xml?address=50+Oakland+St,Wellesley,MA,02481&sensor=true > > > > Here's the entire function: > > addr = '50+Oakland+St,Wellesley,MA,02

Re: [XML-SIG] parsing XML with minidom

2010-04-27 Thread kimmyaf
Now that I look at my file it does not look well formed. Do I have to use a file? I tried to do tree = ET.parse(xml_response) but i got a file IO error... kimmyaf wrote: > > I don't really know... Here's the whole story. > > I am retrieving the xml by calling this link. > > http://maps.go

Re: [XML-SIG] parsing XML with minidom

2010-04-27 Thread kimmyaf
I don't really know... Here's the whole story. I am retrieving the xml by calling this link. http://maps.google.com/maps/api/geocode/xml?address=50+Oakland+St,Wellesley,MA,02481&sensor=true Here's the entire function: addr = '50+Oakland+St,Wellesley,MA,02481' def geocode_addr(addr): hos

Re: [XML-SIG] parsing XML with minidom

2010-04-27 Thread Stefan Behnel
kimmyaf, 26.04.2010 23:14: Stefan Behnel-3 wrote: kimmyaf, 26.04.2010 00:24: Hello. I've only done a litte bit of parsing with minidom before but I'm having trouble getting my values out of this xml. I need the latitude and longitude values in bold. I don't see anything 'bold' in your mail, b

Re: [XML-SIG] parsing XML with minidom

2010-04-27 Thread kimmyaf
Thanks Stefan. I tried this but it's not getting into the for block for some reason. I'll keep trying! Stefan Behnel-3 wrote: > > kimmyaf, 26.04.2010 00:24: >> Hello. I've only done a litte bit of parsing with minidom before but I'm >> having trouble getting my values out of this xml. I need

Re: [XML-SIG] parsing XML with minidom

2010-04-25 Thread Stefan Behnel
kimmyaf, 26.04.2010 00:24: Hello. I've only done a litte bit of parsing with minidom before but I'm having trouble getting my values out of this xml. I need the latitude and longitude values in bold. I don't see anything 'bold' in your mail, but your example tells me what data you mean. Here

Re: [XML-SIG] parsing XML with minidom

2010-02-04 Thread Peter A. Bigot
The variable tag is a list of strings. The method getElementsByTagName takes a single string as its first parameter. Since a list cannot appear as a tag name, the second call to getElementsByTagName returns an empty list. body = dom.getElementsByTagName('body')[0] for route in body.getElemen

Re: [XML-SIG] parsing XML with minidom

2010-02-03 Thread Rajanikanth Jammalamadaka
Try this: from xml.etree.ElementTree import ElementTree doc = ElementTree(file = "t.xml") listOfTags = [] for item in doc.findall(".//route"): listOfTags.append(item.get('tag')) print listOfTags where t.xml is your xml file. Thanks, Raj On Wed, Feb 3, 2010 at 8:04 PM, kimmyaf wrote: