title: How to ensure xml.dom.minidom can parse its own output?
body: <p>I'm trying to serialize some data to xml in a way that can be read back. I'm doing this by manually building a DOM via xml.dom.minidom, and writing it to a file using the included writexml method.</p>
  
  <p>Of particular interest is how I build the text nodes. I do this by initializing a Text object and then setting its data attribute. I'm not sure why the Text object doesn't take its content in the constructor, but that's just the way it in simplemented in xml.dom.minidom.</p>
  
  <p>To give a concrete example, the code looks something like this:</p>
  
  <pre><code>import xml.dom.minidom as dom
  e = dom.Element('node')
  t = dom.Text()
  t.data = "The text content"
  e.appendChild(t)
  dom.parseString(e.toxml())
  </code></pre>
  
  <p>This seemed reasonable to me, particularly since createTextNode itself is implemented exactly like this:</p>
  
  <pre><code>def createTextNode(self, data):
      if not isinstance(data, StringTypes):
          raise TypeError, "node contents must be a string"
      t = Text()
      t.data = data
      t.ownerDocument = self
      return t
  </code></pre>
  
  <p>The problem is that setting the data like this allows us to write text that later cannot be parsed back. To give an example, I am having difficulty with the following character:</p>
  
  <pre><code>you´ll
  </code></pre>
  
  <p>The quote is ord(180), '\xb4'. My question is, what is the correct procedure to encode this data into an xml document suck that I parse the document with minidom to restore the original tree?</p>