title: Error in extracting data from xml files using python
body: <p>I am trying to extract data from a xml file  and trying to print the object names,But I am getting this error:</p>
  
  <pre><code>File "new.py", line 11, in &lt;module&gt;
      dom=ElementTree.parse(image_file)
    File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1182, in parse
      tree.parse(source, parser)
    File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 647, in parse
      source = open(source, "rb")
  IOError: [Errno 2] No such file or directory: 'abc.xml'
  </code></pre>
  
  <p>Although the program knows the file name but still is says no file name.Here is my python program:</p>
  
  <pre><code>import os
  from xml.etree import ElementTree
  path="/home/sultan/Desktop/xmltxt/xmlfiles"
  dirs = os.listdir( path )
  savedir='textfiles'
  for image_file in (dirs):
      if not os.path.isdir(savedir):
          os.mkdir(savedir)
  
  
      dom=ElementTree.parse(image_file)
      labels=dom.findall('object/name')
      for lbl in labels:
         print(lbl)
  </code></pre>
  
  <p>here is the content of my xml file:</p>
  
  <pre><code>&lt;annotation&gt;
  &lt;folder&gt;images&lt;/folder&gt;
  &lt;filename&gt;3rdtrk6.jpg&lt;/filename&gt;
  &lt;segmented&gt;0&lt;/segmented&gt;
  &lt;size&gt;
  &lt;width&gt;1920&lt;/width&gt;
  &lt;height&gt;1080&lt;/height&gt;
  &lt;depth&gt;3&lt;/depth&gt;
  &lt;/size&gt;
  &lt;object&gt;
  &lt;name&gt;truck&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;959&lt;/xmin&gt;
  &lt;ymin&gt;388&lt;/ymin&gt;
  &lt;xmax&gt;1411&lt;/xmax&gt;
  &lt;ymax&gt;889&lt;/ymax&gt;
  &lt;/bndbox&gt;
  &lt;/object&gt;
  &lt;object&gt;
  &lt;name&gt;bus&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;220&lt;/xmin&gt;
  &lt;ymin&gt;264&lt;/ymin&gt;
  &lt;xmax&gt;471&lt;/xmax&gt;
  &lt;ymax&gt;465&lt;/ymax&gt;
  &lt;/bndbox&gt;
  &lt;/object&gt;
  &lt;/annotation&gt;
  </code></pre>