title: python xml xpath query using tag and attribute with ns
body: <p>I must be doing something inherently wrong here, every example I've seen and search for on SO seems to suggest this would work.</p>
  
  <p>I'm trying to use an XPath search with lxml etree library to parse a garmin tcx file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no" ?&gt;
  &lt;TrainingCenterDatabase xmlns="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2 http://www.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd"&gt;
  
    &lt;Workouts&gt;
      &lt;Workout Sport="Biking"&gt;
        &lt;Name&gt;3P2 WK16 - 3&lt;/Name&gt;
        &lt;Step xsi:type="Step_t"&gt;
          &lt;StepId&gt;1&lt;/StepId&gt;
          &lt;Name&gt;[MP19]6:28-6:38&lt;/Name&gt;
          &lt;Duration xsi:type="Distance_t"&gt;
            &lt;Meters&gt;13000&lt;/Meters&gt;
          &lt;/Duration&gt;
          &lt;Intensity&gt;Active&lt;/Intensity&gt;
          &lt;Target xsi:type="Speed_t"&gt;
            &lt;SpeedZone xsi:type="PredefinedSpeedZone_t"&gt;
              &lt;Number&gt;2&lt;/Number&gt;
            &lt;/SpeedZone&gt;
          &lt;/Target&gt;
        &lt;/Step&gt;
       ......
       &lt;/Workout&gt;
  &lt;/Workouts&gt;
  &lt;/TrainingCenterDatabase&gt;
  </code></pre>
  
  <p>I'd like to return the SpeedZone Element only where the type is PredefinedSpeedZone_t. I thought I'd be able to do:</p>
  
  <pre><code>root = ET.parse(open('file.tcx'))
  xsi = {'xsi': 'http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2'}
      for speed_zone in root.xpath(".//xsi:SpeedZone[@xsi:type='PredefinedSpeedZone_t']", namespaces=xsi):
          print speed_zone
  </code></pre>
  
  <p>Though this doesn't seem to be the case. I've tried lots of combinations of removing/adding namespaces and to no avail. If I remove the attribute search and leave it as <code>".//xsi:SpeedZone"</code> then this does return:</p>
  
  <pre><code>&lt;Element {http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2}SpeedZone at 0x2595188&gt;
  </code></pre>
  
  <p>as I'd expect.</p>
  
  <p>I guess I could do it inside the for loop but it just feels like it should be possible on one line!</p>