[EMAIL PROTECTED] wrote: > I tried the tips I found in other posts but I still get 'none' back: > > import easygui as eg > import xml.etree.ElementTree as ET > import sys > > #kml source is: > #<?xml version="1.0" encoding="UTF-8"?> > #<kml xmlns="http://earth.google.com/kml/2.2"> > # <Placemark> > # <name>Simple placemark</name> > # <description>Attached to the ground. Intelligently places itself > # at the height of the underlying terrain.</description> > # <Point> > # <coordinates>-122.0822035425683,37.42228990140251,0</ > coordinates> > # </Point> > # </Placemark> > #</kml> > > > #select a file and open it in python > f_name=eg.fileopenbox("select kml file", "Select kml file") > f_kml=open(f_name,'r') > > #parse and create Elementtree and go to root > tree=ET.parse(f_kml) > kml=tree.getroot() > > #look for description > coord= kml.find('.//description') > print coord > > > _______________________ > > the result is 'None' ... > > If I print out the kml with tostring I can see the entire file and to > me the XPath string also seems correct > > any idea?
This works: >>> url='http://earth.google.com/kml/2.2' >>> coord=kml.find('{%s}Placemark/{%s}Point/{%s}coordinates' % \ (url, url, url)).text >>> print coord '-122.0822035425683,37.42228990140251,0' -Larry -- http://mail.python.org/mailman/listinfo/python-list