[Chicago] xpath query with namespace

Fawad Halim fawad at fawad.net
Mon Dec 11 15:59:43 CET 2006


The syntax is correct, but you're using the wrong namespace. The file at
that URL uses the http://www.topografix.com/GPX/1/0 namespace for wpt.

-fawad

On Mon, December 11, 2006 00:11, sheila miguez wrote:
> 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 _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
>
>
>




More information about the Chicago mailing list