[Chicago] xpath query with namespace
sheila miguez
shekay at gmail.com
Mon Dec 11 07:11:19 CET 2006
How do I specify a namespace when performing this query? As a learning
exercise, I'd like to get all of the wpt elements. In a file without a
xmlns defined, I can use //wpt but I am not sure how to form the query
when a namespace is involved.
small.gpx is based on the example at
http://www.topografix.com/fells_loop.gpx but I've edited most of the
element out for brevity
http://www.topografix.com/gpx/1/1/ gpx schema defined here
nsdict = {'gpxns': 'http://www.topografix.com/GPX/1/1/'}
gpxfile = file('small.gpx')
gpxdoc = etree.parse(gpxfile)
gpxdoc.xpath('//gpxns:wpt', nsdict)
[]
nothing. arg.
this is just one example from a bunch of futzing around. I've played
around with the syntax a lot already. judging from the example at
http://codespeak.net/lxml/api.html#xpath I thought using the dict
would work.
reformatting the hard drive and reinstalling windows hasn't worked. I
might try switching to a mac next. suggestions?
thanks
--
sheila
More information about the Chicago
mailing list