title: Python / Minidom : Iterate on a NodeList
body: <p>I'm making a Python program that parse XML files. I need to iterate over NodeList, but I have an issue doing it with the "for node in NodeList" syntax. </p>
  
  <p>Here is a sample of code  :</p>
  
  <pre><code>docToInclude = parse(node.getAttribute("file"))
  
  print ("childNode count : " , len(docToInclude.documentElement.childNodes))
  print ("childNodes : " , docToInclude.documentElement.childNodes)
  print("")
  
  for i in range(0, len(docToInclude.documentElement.childNodes)):
      print ("i  = ", i , "nodeName = " + docToInclude.documentElement.childNodes[i].nodeName)
  
  print("")
  
  for elementNode in docToInclude.documentElement.childNodes :
      print ("node name : " ,  elementNode.nodeName)
      node.parentNode.insertBefore(elementNode, insertPosition)
  </code></pre>
  
  <p>Here is the output : </p>
  
  <pre><code>childNode count :  3
  childNodes :  [&lt;DOM Text node "'\n\n\t'"&gt;, &lt;DOM Element: messageList at 0x3a4e570&gt;, &lt;DOM Text node "'\n\n'"&gt;]
  
  i  =  0 nodeName = #text
  i  =  1 nodeName = messageList
  i  =  2 nodeName = #text
  
  node name :  #text
  node name :  #text
  </code></pre>
  
  <p>If I iterate with the for node in NodeList syntax, an element is skipped.
  Do you have any idea of this problem origin ?</p>