title: xml to csv conversion in python
body: <p>Here i need to parse the xml and get the values. I need to get attribute element  like 'personid =01' which i couldnt get in this code. And also i need to fetch the grand children node values also. here it is for "SIBLING" and its name tags.BUt i cant hard code it as sibling and fetch the value. And top of all i need to handle multiple attributes and join them to form a unique key which will come as a column in the final table.   </p>
  
  <pre><code>import xml.dom
  import xml.dom.minidom
  
  doc = xml.dom.minidom.parseString('''
  &lt;root&gt;
     &lt;person id="01"&gt; 
        &lt;name&gt; abc&lt;/name&gt; 
        &lt;age&gt;32&lt;/age&gt;
        &lt;address&gt;addr123&lt;/address&gt;
        &lt;siblings&gt;
          &lt;name&gt;&lt;/name&gt;
        &lt;/siblings&gt;
     &lt;/person&gt;
     &lt;person id="02"&gt;
        &lt;name&gt; def&lt;/name&gt;
        &lt;age&gt;22&lt;/age&gt;
        &lt;address&gt;addr456&lt;/address&gt;
        &lt;siblings&gt;
          &lt;name&gt;&lt;/name&gt;
          &lt;name&gt;&lt;/name&gt;
        &lt;/siblings&gt;
     &lt;/person&gt;
  &lt;/root&gt;
  
  ''')
  
  innerlist=[]
  outerlist=[]
  def innerHtml(root):
      text = '' 
      nodes = [ root ]
      while not nodes==[]:
          node = nodes.pop()
          if node.nodeType==xml.dom.Node.TEXT_NODE:
              text += node.wholeText
          else:
              nodes.extend(node.childNodes)
      return text
  
  for statusNode in doc.getElementsByTagName('person'):
      for childNode in statusNode.childNodes:
          if childNode.nodeType==xml.dom.Node.ELEMENT_NODE:
             if innerHtml(childNode).strip() != '':
                innerlist.append(childNode.nodeName+" "+innerHtml(childNode).strip())
      outerlist.append(innerlist)
      innerlist=[]
  #print(outerlist) 
  
  attrlist = []
  nodes = doc.getElementsByTagName('person')
  for node in nodes:
      if 'id' in node.attributes:
          #print(node.attributes['id'].value)
          attrlist.append(node.attributes['id'].value)
  #print(attrlist)
  
  dictionary = dict(zip(attrlist, outerlist))
  print(dictionary) 
  </code></pre>