title: Parsing Stackoverflow Posts.xml data dump file crashes the program, gives ascii encoding error
body: <p>I have downloaded Stackoverflow June 2013 data dump and now in the process of parsing the XML files and storing in MySQL database. I am using Python ElementTree to do it and it keeps crashing and giving me encoding errors.</p>
  
  <p>Snippet of parse code:</p>
  
  <pre><code>post = open('a.xml', 'r')
  a = post.read()  
  tree = xml.parse((a).encode('ascii', 'ignore')) # I also tried .encode('utf-8').strip() it doesn't work
  
  #Get the root node
  
  row = tree.findall("row")
  </code></pre>
  
  <p>It's giving me following errors:</p>
  
  <pre><code>'ascii' codec can't encode character u'\u2019' in position 248: ordinal not in range(128)
  </code></pre>
  
  <p>I also tried using the following but the problem persists.</p>
  
  <pre><code>.encode('ascii', 'ignore')
  </code></pre>
  
  <p>Any advise to fix the problem will be appreciated. Also, if anyone has link to the clean data will also help.</p>
  
  <p>Also, my final goal is to convert the data into RDF, so if anyone has StackOverflow data dump in RDF format, I'll be grateful.</p>
  
  <p>Thanks in advance!</p>
  
  <p>p.s This is the XML row that causes problem and crashes the program:</p>
  
  <pre><code>&lt;row Id="99" PostTypeId="2" ParentId="88" CreationDate="2008-08-01T14:55:08.477" Score="2" Body="&amp;lt;blockquote&amp;gt;&amp;#xD;&amp;#xA;  &amp;lt;p&amp;gt;The actual resolution of gettimeofday() depends on the hardware architecture. Intel processors as well as SPARC machines offer high resolution timers that measure microseconds. Other hardware architectures fall back to the system’s timer, which is typically set to 100 Hz. In such cases, the time resolution will be less accurate. &amp;lt;/p&amp;gt;&amp;#xD;&amp;#xA;&amp;lt;/blockquote&amp;gt;&amp;#xD;&amp;#xA;&amp;#xD;&amp;#xA;&amp;lt;p&amp;gt;I obtained this answer from &amp;lt;a href=&amp;quot;http://www.informit.com/guides/content.aspx?g=cplusplus&amp;amp;amp;seqNum=272&amp;quot; rel=&amp;quot;nofollow&amp;quot;&amp;gt;High Resolution Time Measurement and Timers, Part I&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;" OwnerUserId="25" LastActivityDate="2008-08-01T14:55:08.477" /&gt;
  </code></pre>
  
  <p>Edit: @Arjan the solution you mentioned <a href="https://stackoverflow.com/questions/3224268/python-unicode-encode-error">here</a> doesn't work for me.</p>