title: Read GPX using Python ElementTree.register_namespace?
body: <p>I have been beating my head against the wall for some time now. According to the documentation, this <i>should</i> be simple. All I want to do is read a GPX file. However, GPX files liberally use namespaces, which <i>theoretically</i> make sense. I cannot seem to get ElementTree to read them, though. Here is the code I am trying to use...</p>
  
  <pre><code>def loadGpx(self, sourceFile):
      ElementTree.register_namespace('gpx', 'http://www.topografix.com/GPX/1/1')
      eTree = ElementTree.ElementTree()
      eTree.parse(sourceFile)
  
      print eTree.findall('wpt')
  </code></pre>
  
  <p>To pull out waypoints from a GPX file like this...</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;gpx creator="Garmin Desktop App" version="1.1" 
      xsi:schemaLocation="http://www.topografix.com/GPX/1/1 
                      http://www.topografix.com/GPX/1/1/gpx.xsd 
                      http://www.garmin.com/xmlschemas/WaypointExtension/v1 
                      http://www8.garmin.com/xmlschemas/WaypointExtensionv1.xsd 
                      http://www.garmin.com/xmlschemas/TrackPointExtension/v1 
                      http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd 
                      http://www.garmin.com/xmlschemas/GpxExtensions/v3 
                      http://www8.garmin.com/xmlschemas/GpxExtensionsv3.xsd 
                      http://www.garmin.com/xmlschemas/ActivityExtension/v1 
                      http://www8.garmin.com/xmlschemas/ActivityExtensionv1.xsd 
                      http://www.garmin.com/xmlschemas/AdventuresExtensions/v1 
                      http://www8.garmin.com/xmlschemas/AdventuresExtensionv1.xsd" 
      xmlns="http://www.topografix.com/GPX/1/1" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:wptx1="http://www.garmin.com/xmlschemas/WaypointExtension/v1" 
      xmlns:gpxtrx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" 
      xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" 
      xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" 
      xmlns:abp="http://www.garmin.com/xmlschemas/ActivityExtension/v1" 
      xmlns:adv="http://www.garmin.com/xmlschemas/AdventuresExtensions/v1"&gt;
  
      &lt;metadata&gt;
          &lt;link href="http://www.garmin.com"&gt;
            &lt;text&gt;Garmin International&lt;/text&gt;
          &lt;/link&gt;
          &lt;time&gt;2012-01-17T03:21:12Z&lt;/time&gt;
          &lt;bounds maxlat="45.708811283111572" maxlon="-121.3884991966188" 
                  minlat="45.407062936574221" minlon="-121.54939779080451" /&gt;
      &lt;/metadata&gt;
  
    &lt;wpt lat="45.708682453259826" lon="-121.51224257424474"&gt;
      &lt;time&gt;2012-01-06T19:00:02Z&lt;/time&gt;
      &lt;name&gt;1-State and First, start MHL&lt;/name&gt;
      &lt;sym&gt;Bike Trail&lt;/sym&gt;
      &lt;extensions&gt;
        &lt;gpxx:WaypointExtension&gt;
          &lt;gpxx:DisplayMode&gt;SymbolAndName&lt;/gpxx:DisplayMode&gt;
        &lt;/gpxx:WaypointExtension&gt;
      &lt;/extensions&gt;
    &lt;/wpt&gt;
  
    &lt;wpt lat="45.615267734974623" lon="-121.43857721239328"&gt;
      &lt;time&gt;2012-01-07T15:38:14Z&lt;/time&gt;
      &lt;name&gt;10-Right at fork staying on Huskey Rd&lt;/name&gt;
      &lt;sym&gt;Bike Trail&lt;/sym&gt;
      &lt;extensions&gt;
        &lt;gpxx:WaypointExtension&gt;
          &lt;gpxx:DisplayMode&gt;SymbolAndName&lt;/gpxx:DisplayMode&gt;
        &lt;/gpxx:WaypointExtension&gt;
      &lt;/extensions&gt;
    &lt;/wpt&gt;
  </code></pre>
  
  <p>True, it will take more than just <code>print eTree.findall('wpt')</code>, but if I can get that far, I have worked with xml before. That part is easy. This namespace thing though, is driving me nuts.</p>
  
  <p>I thank you in advance. This is driving me nuts.</p>