title: xml.dom.minidom.parse() failing when XML attribute contains unicode
body: <p>I'm querying a web service using urllib2.request and receiving XML. If I violate the web service's rate limit (1 call/second), I receive HTML back saying I've violated the rate limit.</p>
  
  <p>Even though I can time.sleep() for 2-3 seconds after each call, I still, for whatever reason, violate the rate limit.</p>
  
  <p>To test that my response is either XML or HTML, I'm using xml.dom.minidom() and then testing for the presence of an html element</p>
  
  <pre><code>try:
      dom = xml.dom.minidom.parseString(response_text)
    except xml.parsers.expat.ExpatError:
      return False
  
    if len(dom.getElementsByTagName('html')) == 0:
      return True
    else:
      return False
  </code></pre>
  
  <p>This gets the job done but I've run into a case where one of the XML attributes contains XML. In that case, the parseString() command fails with</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/opt/python/default-2.6/lib/python2.6/xml/dom/minidom.py", line 1918, in     parse
      return expatbuilder.parse(file)
    File "/opt/python/default-2.6/lib/python2.6/xml/dom/expatbuilder.py", line 924, in parse
      result = builder.parseFile(fp)
    File "/opt/python/default-2.6/lib/python2.6/xml/dom/expatbuilder.py", line 207, in parseFile
      parser.Parse(buffer, 0)
  xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 3125
  </code></pre>
  
  <p>In this case, column 3125 is part of some attribute value text that contains ampersand-pound-x-9  (Stackoverflow is hiding my unicode).</p>
  
  <p>Should xml.dom.minidom be able to handle this? Could there be another issue with the XML besides this that's causing the parsing to fail?</p>
  
  <p>Additionally, I'm open to other ways of handling this type of situation if the community has one.</p>
  
  <p>If it helps, here is what the web service returns when I've violated their rate limit:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="eng"&gt;
      &lt;head&gt;
          &lt;title&gt;Service Temporarily Unavailable - Rate Limited&lt;/title&gt;
      &lt;/head&gt; 
      &lt;body style="text-align:center;background-color:white;"&gt; 
          &lt;h1&gt;Service Temporarily Unavailable&lt;/h1&gt;
          &lt;hr /&gt;
          &lt;div&gt;
              You have used this service too often in a short time.  Please wait before using this service again.
              &lt;br/&gt;&lt;br/&gt;
              Please visit the &lt;a href="http://wiki.xxxx.com/index.php?title=API_Usage"&gt;wiki&lt;/a&gt; for more details.
          &lt;/div&gt; 
      &lt;/body&gt; 
  &lt;/html&gt;
  </code></pre>