title: Python minidom: list childnode attributes per parent tag
body: <p>I have,</p>
  
  <pre><code>&lt;parent id="1"&gt;
      &lt;child id="white"&gt;&lt;/child&gt;
      &lt;child id="red"&gt;&lt;/child&gt;
  &lt;/parent&gt;
  &lt;parent id="2"&gt;
      &lt;child id="green"&gt;&lt;/child&gt;
      &lt;child id="gray"&gt;&lt;/child&gt;
  &lt;/parent&gt;
  </code></pre>
  
  <p>I need this output,</p>
  
  <pre><code>1 
   white
   red
  2
   green
   gray
  </code></pre>
  
  <p>This is how I am doing it,</p>
  
  <pre><code>parent = xmldoc.getElementsByTagName('parent')
  for item in parent:
      child = xmldoc.getElementsByTagName('child')
      child_id = child.getAttribute('id')
      for child_id in child:
          print child_id
  </code></pre>
  
  <p>Of course, I'm getting it wrong, but do not know how to loop through these parent ids and collect each list individually. I would appreciate some help!</p>