title: Python Parse XML using xml.dom.minidom - Extract Items within List
body: <p>I have lengthy xml this actually ebay listings using ebay api, I am trying to extract following structure in that xml dom:</p>
  
  <p>I am only putting the segment that I am having trouble with, please let me know if you need to see the entire file, I could upload it to a location or do an attachment as a picture.</p>
  
  <pre><code>&lt;ItemSpecifics&gt;
  &lt;NameValueList&gt;
  &lt;Name&gt;Room&lt;/Name&gt;
  &lt;Value&gt;Living Room&lt;/Value&gt;
  &lt;/NameValueList&gt;
  &lt;NameValueList&gt;
  &lt;Name&gt;Type&lt;/Name&gt;
  &lt;Value&gt;Sofa Set&lt;/Value&gt;
  &lt;/NameValueList&gt;
  &lt;NameValueList&gt;...&lt;/NameValueList&gt;
  &lt;NameValueList&gt;
  &lt;Name&gt;Upholstery Fabric&lt;/Name&gt;
  &lt;Value&gt;Microfiber&lt;/Value&gt;
  &lt;/NameValueList&gt;
  &lt;NameValueList&gt;
  &lt;Name&gt;Color&lt;/Name&gt;
  &lt;Value&gt;Beiges&lt;/Value&gt;
  &lt;/NameValueList&gt;
  &lt;NameValueList&gt;
  &lt;Name&gt;Style&lt;/Name&gt;
  &lt;Value&gt;Contemporary&lt;/Value&gt;
  &lt;/NameValueList&gt;
  &lt;NameValueList&gt;
  &lt;Name&gt;MPN&lt;/Name&gt;
  &lt;Value&gt;F7615, F7616, F7617, F7618, F7619, F7620&lt;/Value&gt;
  &lt;/NameValueList&gt;
  &lt;/ItemSpecifics&gt;
  </code></pre>
  
  <p>Here is dom structure for another ebay item:</p>
  
  <pre><code>ItemSpecifics&gt;
  &lt;NameValueList&gt;
  &lt;Name&gt;Brand&lt;/Name&gt;
  &lt;Value&gt;Nikon&lt;/Value&gt;
  &lt;/NameValueList&gt;
  &lt;NameValueList&gt;
  &lt;Name&gt;Model&lt;/Name&gt;
  &lt;Value&gt;D3100&lt;/Value&gt;
  &lt;/NameValueList&gt;
  &lt;NameValueList&gt;
  &lt;Name&gt;MPN&lt;/Name&gt;
  &lt;Value&gt;9798&lt;/Value&gt;
  &lt;/NameValueList&gt;
  &lt;NameValueList&gt;
  &lt;Name&gt;Type&lt;/Name&gt;
  &lt;Value&gt;Digital SLR&lt;/Value&gt;
  &lt;/NameValueList&gt;
  &lt;NameValueList&gt;
  &lt;Name&gt;Megapixels&lt;/Name&gt;
  &lt;Value&gt;14.2 MP&lt;/Value&gt;
  &lt;/NameValueList&gt;
  &lt;NameValueList&gt;
  &lt;Name&gt;Optical Zoom&lt;/Name&gt;
  &lt;Value&gt;3.1x&lt;/Value&gt;
  &lt;/NameValueList&gt;
  &lt;NameValueList&gt;
  &lt;Name&gt;Screen Size&lt;/Name&gt;
  &lt;Value&gt;3"&lt;/Value&gt;
  &lt;/NameValueList&gt;
  &lt;NameValueList&gt;
  &lt;Name&gt;Color&lt;/Name&gt;
  &lt;Value&gt;Black&lt;/Value&gt;
  &lt;/NameValueList&gt;
  &lt;/ItemSpecifics&gt;
  </code></pre>
  
  <p>But when I tried to extract above elements I endup getting following error:</p>
  
  <pre><code>   attID=att.attributes.getNamedItem('Name').nodeValue
  AttributeError: 'NoneType' object has no attribute 'nodeValue'
  </code></pre>
  
  <p>this is what I get right after I parse response:</p>
  
  <pre><code>[&lt;DOM Element: NameValueList at 0x103398878&gt;, &lt;DOM Element: NameValueList at 0x103398ab8&gt;, &lt;DOM Element: NameValueList at 0x103398cf8&gt;, &lt;DOM Element: NameValueList at 0x103398f38&gt;, &lt;DOM Element: NameValueList at 0x1033b31b8&gt;, &lt;DOM Element: NameValueList at 0x1033b33f8&gt;, &lt;DOM Element: NameValueList at 0x1033b3638&gt;, &lt;DOM Element: NameValueList at 0x1033b3878&gt;]
  </code></pre>
  
  <p>And this is what I get inside my for loop before getting the error:</p>
  
  <pre><code>&lt;DOM Element: NameValueList at 0x103398878&gt;
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>  results = {}
    attributeSet=response.getElementsByTagName('NameValueList')
    print attributeSet
    attributes={}
    for att in attributeSet:
      print att
      attID=att.attributes.getNamedItem('Name').nodeValue
      attValue=getSingleValue(att,'Value')
      attributes[attID]=attValue
    result['attributes']=attributes
    return result
  </code></pre>
  
  <p>This is my xml request method:</p>
  
  <pre><code>def sendRequest(apicall,xmlparameters):
    connection = httplib.HTTPSConnection(serverUrl)
    connection.request("POST", '/ws/api.dll', xmlparameters, getHeaders(apicall))
    response = connection.getresponse()
    if response.status != 200:
      print "Error sending request:" + response.reason
    else: 
      data = response.read()
      connection.close()
    return data
  </code></pre>