title: How to force MSXML2 to load non UTF-8 encoded XML
body: <p>I need to load an <code>ANSI</code> encoded XML file using MSXML2.DOMDocument, but that file does not contain the <code>&lt;?xml version="1.0" encoding="Windows-1250"?&gt;</code> line. The XML parser fails with <code>An invalid character was found in the text content</code> because XML data contains some national characters.</p>
  
  <p>I tried to add a processing instructions like this but it does not do anything.</p>
  
  <pre><code>Dim xDoc As MSXML2.DOMDocument
  Set xDoc = New MSXML2.DOMDocument
  
  Dim PI
  Set PI = xDoc.createProcessingInstruction("xml", "version='1.0' encoding='windows-1250'")
  xDoc.insertBefore PI, xDoc.childNodes.Item(0)
  
  If xDoc.Load("C:\Test.xml") Then
      Debug.Print "Success"
  Else
      Debug.Print xDoc.parseError.reason
  End If
  
  Set xDoc = Nothing
  </code></pre>
  
  <p>Is there a way to force the MSXML2 to use user-defined encoding BEFORE I call the .load method?</p>