title: Reading PASCAL VOC annotations in python
body: <p>I have annotations in xml files such as this one, which follows the PASCAL VOC convention:</p>
  
  <pre><code>&lt;annotation&gt;
  &lt;folder&gt;training&lt;/folder&gt;
  &lt;filename&gt;chanel1.jpg&lt;/filename&gt;
  &lt;source&gt;
  &lt;database&gt;synthetic initialization&lt;/database&gt;
  &lt;annotation&gt;PASCAL VOC2007&lt;/annotation&gt;
  &lt;image&gt;synthetic&lt;/image&gt;
  &lt;flickrid&gt;none&lt;/flickrid&gt;
  &lt;/source&gt;
  &lt;owner&gt;
  &lt;flickrid&gt;none&lt;/flickrid&gt;
  &lt;name&gt;none&lt;/name&gt;
  &lt;/owner&gt;
  &lt;size&gt;
  &lt;width&gt;640&lt;/width&gt;
  &lt;height&gt;427&lt;/height&gt;
  &lt;depth&gt;3&lt;/depth&gt;
  &lt;/size&gt;
  &lt;segmented&gt;0&lt;/segmented&gt;
  &lt;object&gt;
  &lt;name&gt;chanel&lt;/name&gt;
  &lt;pose&gt;Unspecified&lt;/pose&gt;
  &lt;truncated&gt;0&lt;/truncated&gt;
  &lt;difficult&gt;0&lt;/difficult&gt;
  &lt;bndbox&gt;
  &lt;xmin&gt;344&lt;/xmin&gt;
  &lt;ymin&gt;10&lt;/ymin&gt;
  &lt;xmax&gt;422&lt;/xmax&gt;
  &lt;ymax&gt;83&lt;/ymax&gt;
  &lt;/bndbox&gt;
  &lt;/object&gt;
  &lt;object&gt;
  &lt;name&gt;chanel&lt;/name&gt;
  &lt;pose&gt;Unspecified&lt;/pose&gt;
  &lt;truncated&gt;0&lt;/truncated&gt;
  &lt;difficult&gt;0&lt;/difficult&gt;
  &lt;bndbox&gt;
  &lt;xmin&gt;355&lt;/xmin&gt;
  &lt;ymin&gt;165&lt;/ymin&gt;
  &lt;xmax&gt;443&lt;/xmax&gt;
  &lt;ymax&gt;206&lt;/ymax&gt;
  &lt;/bndbox&gt;
  &lt;/object&gt;
  &lt;/annotation&gt;
  </code></pre>
  
  <p>What is the cleanest way of retrieving for example the fields <code>filename</code> and <code>bndbox</code> in Python?</p>
  
  <p>I was trying to ElementTree, which seems to be the official Python solution, but I can't make it work.</p>
  
  <p>My code so far:</p>
  
  <pre><code>from xml.etree import ElementTree as ET
  tree = ET.parse("data/all/annotations/" + file)
  fn = tree.find('filename').text
  boxes = tree.findall('bndbox')
  </code></pre>
  
  <p>this produces</p>
  
  <pre><code>fn == 'chanel1.jpg'
  boxes == []
  </code></pre>
  
  <p>So it succesfully extracts the <code>filename</code> field, but not the <code>bndbox</code>'es.</p>