title: How to replace HEX character in an xml document?
body: <p>I'm trying to import an xml file into vb.net XmlDocument but am getting the error:</p>
  
  <blockquote>
    <p>'.', hexadecimal value 0x00, is an invalid character. Line 94, position 1.</p>
  </blockquote>
  
  <p>I'm wondering if there is a way to replace the hex character 0x00<br>
  The following are lines 92,93,94 the file ends on line 94</p>
  
  <pre><code>92 |    &lt;/request&gt;
  93 |&lt;/rpc&gt; &lt;!-- XML Finishes here --&gt;
  94 |
  </code></pre>
  
  <p>Thanks for any help.</p>
  
  <p>EDIT: adding code used to get the file.</p>
  
  <pre><code>Dim fs As FileStream = File.Open(FileName, FileMode.Open, FileAccess.Read)
  Dim buffer(fs.Length) As Byte
  fs.Read(buffer, 0, fs.Length)
  Dim xmlString As String = System.Text.UTF8Encoding.UTF8.GetString(buffer)
  fs.close()
  
  Doc.LoadXml(xmlString.Trim)
  </code></pre>
  
  <p>I am using System.Text.UTF8Encoding.UTF8.GetString(buffer) because the file encoding is not always UTF-8. Unfortunatly I don't have controll over the xml file as we are receiving it from an external source who wont change the way the file is generated as it is used by others.</p>
  
  <p>What I want to do is basically get the file into the string then either chop off the end of it from the last > and then append my own > or just replace the HEX character with an empty string.</p>