title: Hexadecimal value 0x00 is a invalid character
body: <p>I am generating an XML document from a StringBuilder, basically something like:<br></p>
  
  <pre><code>string.Format("&lt;text&gt;&lt;row&gt;{0}&lt;/row&gt;&lt;col&gt;{1}&lt;/col&gt;&lt;textHeight&gt;{2}&lt;/textHeight&gt;&lt;textWidth&gt;{3}&lt;/textWidth&gt;&lt;data&gt;{4}&lt;/data&gt;&lt;rotation&gt;{5}&lt;/rotation&gt;&lt;/text&gt;
  </code></pre>
  
  <p>Later, something like:</p>
  
  <pre><code>XmlDocument document = new XmlDocument();
  document.LoadXml(xml);
  XmlNodeList labelSetNodes = document.GetElementsByTagName("labels");
  for (int index = 0; index &lt; labelSetNodes.Count; index++)
  {
      //do something
  }
  </code></pre>
  
  <p>All the data comes from a database.
  Recently I've had a few issues with the error:</p>
  
  <blockquote>
    <p>Hexadecimal value 0x00 is a invalid character, line 1, position nnnnn</p>
  </blockquote>
  
  <p>But its not consistent.
  Sometimes some 'blank' data will work.
  The 'faulty' data works on some PCs, but not others.</p>
  
  <p>In the database, the data is always a blank string. It is never 'null'
  and in the XML file, it comes out as <code>&lt; data&gt;&lt; /data&gt;</code>, i.e. no character between opening and closing. (but not sure if this can be relied on as I am pulling it from the 'immediate' window is vis studio and pasting it into textpad).</p>
  
  <p>There is possibly differences in the versions of sql server (2008 is where it would fail, 2005 would work) and collation too.
  Not sure if any of these are likely causes?</p>
  
  <p>But exactly the same code and data will sometimes fail. Any ideas where the problem lies?</p>