title: Problems parsing an XML files using python using ElementTree
body: <p>I have a bunch of videos and XML files which contain data about objects in the files. I am trying to write some function which compares each frame of each video against that videos XML file but when I loop through a sub-sub element of the root and print its attributes not all the objects are being found. An example XML file is linked <a href="https://pastebin.com/HarkUz0X" rel="nofollow noreferrer">here</a></p>
  
  <p>I wrote these two functions</p>
  
  <pre><code>def setUP():
      os.chdir('/home/abdi/Desktop/TestOpt/FishCLEF2015- TestDataset/Combined/')
      listOfGT=[]
  
  
  
   for file in glob.glob("*.flv"):
          number,types=file.split(".")
          listOfGT.append(number)
      #print(len(listOfGT))
      total=0
      for names in listOfGT:
          total+=1
          print ("**** New File is {} ****".format(str(names) +".xml"))
  
          tree = ET.parse(str(names) + ".xml")  
          root = tree.getroot()
          NumberOfframes=LastFrames(root)
          for frames in root:
              print("For Frame: {}".format(frames.attrib["id"]))
              jakoObject(frames,NumberOfframes,names)
  </code></pre>
  
  <p>This sets up everything by looping through all the files finding the root structure and looping through each sublist which corresponds to 1 frame in the image</p>
  
  <pre><code>def jakoObject(frames,NumberOfframes,names):
  cam = cv.VideoCapture(str(names) + ".flv")
  frame_count=0
  while frame_count != NumberOfframes:
      ret,frame = cam.read()
      attrib=frames.attrib["id"]
  
      if (frame_count==NumberOfframes):
          print("Yatta")
          break
      else:
          frame_count+=1
  
      if (frame_count==int(attrib)):
          for objects in frames:
              # print("For Frame: {} and object {}".format(frames.attrib["id"],franmes.objects.attrib["id"]))
              print(objects.attrib)
  </code></pre>
  
  <p>I then use this function to play through the video, if the current frame number is equal the the current frame number found through the root structure then a loop through each sublist named objects is started. </p>
  
  <p>I have called printed the attributed of the file. However, what happens is that for a lot of the "object" sublists no attributes are found. But the attributes are found for another frame inside the same XML file. </p>
  
  <p>For the file linked above, the output is </p>
  
  <p><img src="https://i.stack.imgur.com/0B56j.png" alt="output"> </p>