title: How to get parent tag while using XPaths in xml.etree.elementree with python 2.6.4
body: <p>I am newbie to this forum.</p>
  
  <p>I am trying to retrieve data from xml.etree.cElementTree.</p>
  
  <p>i have the following code</p>
  
  <p><strong>Code Snippet</strong></p>
  
  <pre><code>import xml.etree.cElementTree as ET
  
  xmldata ="""
  &lt;pipeline&gt;
      &lt;ep_150&gt;
          &lt;stage name="lay" longname="layout" department="layout" process="production"&gt;
              &lt;review name="R1" reviewer="sridhar reddy" role="supervisor" id="p1234"&gt;
              &lt;/review&gt;
          &lt;/stage&gt;
          &lt;stage name="lip" longname="lipsync" department="lipsync" process="production"&gt;
              &lt;review name="R2" reviewer="someone" role="supervisor" id="p2345"&gt;
              &lt;/review&gt;
          &lt;/stage&gt;
          &lt;stage name="blk" longname="blocking" department="animation" process="production"&gt;
              &lt;review name="R3" reviewer="sudeepth" role="supervisor" id="p4645" dependson='R1'&gt;
              &lt;/review&gt;
              &lt;review name="R4" reviewer="chandu" role="director" id="p5678"&gt;
              &lt;/review&gt;
          &lt;/stage&gt;
          &lt;stage name="pri" longname="primary" department="animation" process="production"&gt;
              &lt;review name="R5" reviewer="sudeepth" role="supervisor" id="p4645" style="dep" &gt;
              &lt;/review&gt;
              &lt;review name="R6" reviewer="sudeepth" role="bld_supervisor" id="p2556" style="dep"&gt;
              &lt;/review&gt;
          &lt;/stage&gt;
          &lt;stage name="sec" longname="secondary" department="animation" process="production"&gt;
              &lt;review name="R7" reviewer="sha" role="supervisor" id="p1234" style="dep"&gt;
              &lt;/review&gt;
              &lt;review name="R8" reviewer="chandu" role="director" id="p5678"&gt;
              &lt;/review&gt;
          &lt;/stage&gt;
      &lt;/ep_150&gt;
  &lt;/pipeline&gt;
  """
  root = ET.fromstring(xmldata)
  
  stages = root.findall("./ep_150/stage")
  
  print 'Stages in animation department....\n'
  
  for stage in stages:
  
      if stage.attrib['department']=='animation':
          print stage.attrib['name']
  
  review = root.findall("./ep_150/stage/review")        
  
  print '\n\nreviews for id=p4645\n'
  
  for rev in review:
  
      if rev.attrib['id']=='p4645':
          print (rev.attrib['name'])
  </code></pre>
  
  <p>with the above code i am getting the result as below</p>
  
  <p>Stages in animation department....</p>
  
  <p>blk</p>
  
  <p>pri</p>
  
  <p>sec</p>
  
  <p>reviews for id=p4645</p>
  
  <p>R3</p>
  
  <p>R5</p>
  
  <p><strong>But i need the output for second half as</strong></p>
  
  <p>reviewes for id=p4645</p>
  
  <p>blk - R3</p>
  
  <p>pri - R5</p>
  
  <p>i.e, i need the parent tag of the element</p>