Message from discussion
parsing XML with minidom
Received: by 10.223.25.203 with SMTP id a11mr987070fac.1.1272256697974;
Sun, 25 Apr 2010 21:38:17 -0700 (PDT)
X-BeenThere: python-xml-sig@googlegroups.com
Received: by 10.213.59.76 with SMTP id k12ls10474167ebh.3.p; Sun, 25 Apr 2010
21:38:17 -0700 (PDT)
Received: by 10.213.95.139 with SMTP id d11mr436429ebn.20.1272256697161;
Sun, 25 Apr 2010 21:38:17 -0700 (PDT)
Received: by 10.213.95.139 with SMTP id d11mr436428ebn.20.1272256697125;
Sun, 25 Apr 2010 21:38:17 -0700 (PDT)
Return-Path: <xml-sig-bounces+python-xml-sig-garchive-10127=googlegroups....@python.org>
Received: from mail.python.org (mail.python.org [82.94.164.166])
by gmr-mx.google.com with ESMTP id 11si223637ewy.13.2010.04.25.21.38.16;
Sun, 25 Apr 2010 21:38:16 -0700 (PDT)
Received-SPF: pass (google.com: best guess record for domain of xml-sig-bounces+python-xml-sig-garchive-10127=googlegroups....@python.org designates 82.94.164.166 as permitted sender) client-ip=82.94.164.166;
Received: from albatross.python.org (localhost [127.0.0.1])
by mail.python.org (Postfix) with ESMTP id E54B5E753
for <python-xml-sig-garchive-10127@googlegroups.com>; Mon, 26 Apr 2010 06:38:15 +0200 (CEST)
X-Original-To: xml-...@python.org
Delivered-To: xml-...@mail.python.org
Received: from albatross.python.org (localhost [127.0.0.1])
by mail.python.org (Postfix) with ESMTP id E75BCC797
for <xml-...@python.org>; Mon, 26 Apr 2010 00:24:54 +0200 (CEST)
X-Spam-Status: OK 0.014
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'python': 0.07; 'subject:]
': 0.13; 'maybe': 0.14; '02481': 0.16; 'context:': 0.16;
'example?': 0.16; 'getattribute': 0.16; 'message-
id:@talk.nabble.com': 0.16; 'nabble.com.': 0.16;
'received:192.168.236': 0.16; 'received:192.168.236.156': 0.16;
'received:216.139': 0.16; 'received:216.139.236': 0.16;
'received:216.139.236.158': 0.16; 'received:isper.nabble.com':
0.16; 'received:kuber.nabble.com': 0.16; 'received:nabble.com':
0.16; 'subject:XML': 0.16; 'tag': 0.16; 'url:nabble': 0.16;
'url:old': 0.16; 'wellesley,': 0.16; 'xml.': 0.16; 'values': 0.24;
"i'm": 0.26; 'archive': 0.28; 'function': 0.28; "i've": 0.29;
'done': 0.29; 'tried': 0.30; 'list': 0.30; 'correct': 0.30;
'subject:[': 0.31; 'item': 0.31; 'things.': 0.32; 'received:192':
0.34; 'think': 0.34; 'several': 0.35; 'but': 0.36; 'getting':
0.37; 'charset:us-ascii': 0.37; 'location': 0.38;
'received:192.168': 0.38; 'skip:d 40': 0.38; 'trouble': 0.38;
'to:addr:python.org': 0.39; 'code:': 0.39; 'having': 0.39;
'states': 0.62; 'route': 0.62; 'hello.': 0.63; 'view': 0.64;
'body': 0.70; 'political': 0.71; 'country': 0.72; 'united': 0.72;
'usa': 0.74; 'lat': 0.84; 'to:addr:xml-sig': 0.89; 'st,': 0.91
Received: from localhost (HELO mail.python.org) (127.0.0.1)
by albatross.python.org with SMTP; 26 Apr 2010 00:24:54 +0200
Received: from kuber.nabble.com (kuber.nabble.com [216.139.236.158])
(using TLSv1 with cipher AES256-SHA (256/256 bits))
(No client certificate requested)
by mail.python.org (Postfix) with ESMTPS
for <xml-...@python.org>; Mon, 26 Apr 2010 00:24:54 +0200 (CEST)
Received: from isper.nabble.com ([192.168.236.156])
by kuber.nabble.com with esmtp (Exim 4.63)
(envelope-from <boun...@nabble.com>) id 1O6AFx-0007lh-C9
for xml-...@python.org; Sun, 25 Apr 2010 15:24:53 -0700
Message-ID: <28359328.p...@talk.nabble.com>
Date: Sun, 25 Apr 2010 15:24:53 -0700 (PDT)
From: kimmyaf <flahert...@hotmail.com>
To: xml-...@python.org
MIME-Version: 1.0
X-Nabble-From: flahert...@hotmail.com
X-Mailman-Approved-At: Mon, 26 Apr 2010 06:37:43 +0200
Subject: [XML-SIG] parsing XML with minidom
X-BeenThere: xml-...@python.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: XML Processing in Python <xml-sig.python.org>
List-Unsubscribe: <http://mail.python.org/mailman/options/xml-sig>,
<mailto:xml-sig-requ...@python.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/xml-sig>
List-Post: <mailto:xml-...@python.org>
List-Help: <mailto:xml-sig-requ...@python.org?subject=help>
List-Subscribe: <http://mail.python.org/mailman/listinfo/xml-sig>,
<mailto:xml-sig-requ...@python.org?subject=subscribe>
Sender: xml-sig-bounces+python-xml-sig-garchive-10127=googlegroups....@python.org
Errors-To: xml-sig-bounces+python-xml-sig-garchive-10127=googlegroups....@python.org
X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com:
best guess record for domain of xml-sig-bounces+python-xml-sig-garchive-10127=googlegroups....@python.org
designates 82.94.164.166 as permitted sender) smtp.mail=xml-sig-bounces+python-xml-sig-garchive-10127=googlegroups....@python.org;
dkim=pass header...@python.org
X-Original-Sender: flahert...@hotmail.com
Content-Type: text/plain; charset=ISO-8859-1
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've tried several things. I think that I am
getting into the location tag but maybe the getAttribute function is not
correct for this example?
<GeocodeResponse>
<status>OK</status>
<result>
<type>street_address</type>
<formatted_address>50 Oakland St, Wellesley, MA 02481,
USA</formatted_address>
<address_component>
<long_name>50</long_name>
<short_name>50</short_name>
<type>street_number</type>
</address_component>
<address_component>
<long_name>Oakland St</long_name>
<short_name>Oakland St</short_name>
<type>route</type>
</address_component>
<address_component>
<long_name>Wellesley</long_name>
<short_name>Wellesley</short_name>
<type>locality</type>
<type>political</type>
</address_component>
<address_component>
<long_name>Wellesley</long_name>
<short_name>Wellesley</short_name>
<type>administrative_area_level_3</type>
<type>political</type>
</address_component>
<address_component>
<long_name>Norfolk</long_name>
<short_name>Norfolk</short_name>
<type>administrative_area_level_2</type>
<type>political</type>
</address_component>
<address_component>
<long_name>Massachusetts</long_name>
<short_name>MA</short_name>
<type>administrative_area_level_1</type>
<type>political</type>
</address_component>
<address_component>
<long_name>United States</long_name>
<short_name>US</short_name>
<type>country</type>
<type>political</type>
</address_component>
<address_component>
<long_name>02481</long_name>
<short_name>02481</short_name>
<type>postal_code</type>
</address_component>
<geometry>
<location>
<lat>42.3118520</lat>
<lng>-71.2632680</lng>
</location>
<location_type>ROOFTOP</location_type>
<viewport>
<southwest>
<lat>42.3093524</lat>
<lng>-71.2665476</lng>
</southwest>
<northeast>
<lat>42.3156476</lat>
<lng>-71.2602524</lng>
</northeast>
</viewport>
</geometry>
</result>
</GeocodeResponse>
Code:
body = dom.getElementsByTagName('GeocodeResponse')[0]
for item in body.getElementsByTagName('location'):
lat = item.getAttribute('lat')
lng = item.getAttribute('lng')
--
View this message in context: http://old.nabble.com/parsing-XML-with-minidom-tp28359328p28359328.html
Sent from the Python - xml-sig mailing list archive at Nabble.com.
_______________________________________________
XML-SIG maillist - XML-...@python.org
http://mail.python.org/mailman/listinfo/xml-sig
--
You received this message because you are subscribed to the Google Groups "Python: XML SIG" group.
To post to this group, send email to python-xml-sig@googlegroups.com.
To unsubscribe from this group, send email to python-xml-sig+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/python-xml-sig?hl=en.