title: MSXML2.DOMDocument Object required error if file extension is not .xml
body: <p>Working on an application to retreive shipping rates as XML from a web service.  The web service is PHP based.  The client is VB Script, specifically HTA. </p>
  
  <p>During initial development I used an XML file on the server as a test.  Here is the content of that file:</p>
  
  <pre><code>&lt;shipping&gt;
      &lt;rate&gt;
          &lt;method&gt;FEDEX GROUND&lt;/method&gt;
          &lt;description&gt;FedEx Ground&lt;/description&gt;
          &lt;amount&gt;10.00&lt;/amount&gt;
      &lt;/rate&gt;
      &lt;rate&gt;
          &lt;method&gt;FEDEX 2 DAY&lt;/method&gt;
          &lt;description&gt;FedEx 2nd Day&lt;/description&gt;
          &lt;amount&gt;20.00&lt;/amount&gt;
      &lt;/rate&gt;
      &lt;rate&gt;
          &lt;method&gt;FEDEX NEXT DAY&lt;/method&gt;
          &lt;description&gt;FedEx Next Day&lt;/description&gt;
          &lt;amount&gt;30.00&lt;/amount&gt;
      &lt;/rate&gt;
  &lt;/shipping&gt;
  </code></pre>
  
  <p>When I use MSXML2.ServerXMLHTTP to get that file I have no issues using MSXML2.DOMDocument to parse the XML.  </p>
  
  <p>If I attempt to get the exact same XML from a PHP script, or even if I copy the XML file to a filename with a non-xml extension, like .txt, I get an Object Required error trying to access the document elements. </p>
  
  <p>When getting the data from PHP I am setting the header like so: </p>
  
  <pre><code>header('Content-Type: application/xml; charset=utf-8');
  </code></pre>
  
  <p>Here is the VB Script code:</p>
  
  <pre><code>Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
  xmlhttp.open "GET", "http://craig.clearos.lan/c9pets/api/shippingRates", False
  xmlhttp.send
  results=xmlhttp.ResponseText
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")
  xmlDoc.load(xmlhttp.responseXML)
  Set ratesNodeCollection = xmlDoc.DocumentElement.getElementsByTagName("rate")
  </code></pre>
  
  <p>This errors out on the last line with "Object required: 'xmlDoc.DocumentElement'"</p>
  
  <p>If I change line 2 to this</p>
  
  <pre><code>'xmlhttp.open "GET", "http://craig.clearos.lan/sage/hello.xml", False
  </code></pre>
  
  <p>it works as expected.</p>
  
  <p>Again, I have verified that the PHP code and the .txt file contain the exact same XML as the .xml file.</p>
  
  <p>I have added parseError trapping and I'm getting the message "XML document must have a top level element."  This makes no sense to me.  There is a top level element named   I've also added  to the .xml file and the output of PHP.  This did not change anything.  I tried setting the header to text/xml instead of application/xml, which also did nothing.</p>
  
  <p>For reference here is the very simple php code that builds the XML. </p>
  
  <pre><code>$shipping=array(0=&gt;array('method'=&gt;'FEDEX GROUND', 'description'=&gt;'FedEx Ground', 'amount'=&gt;'10.00'),
      1=&gt;array('method'=&gt;'FEDEX 2 DAY', 'description'=&gt;'FedEx 2nd Day', 'amount'=&gt;'20.00'),
      2=&gt;array('method'=&gt;'FEDEX NEXT DAY', 'description'=&gt;'FedEx Next Day', 'amount'=&gt;'30.00'));
  $xml=new SimpleXMLElement('&lt;shipping/&gt;');
  foreach($shipping as $row){
      $rate=$xml-&gt;addChild('rate');
      $rate-&gt;addChild('method', $row['method']);
      $rate-&gt;addChild('description', $row['description']);
      $rate-&gt;addChild('amount', $row['amount']);
  }
  Header('Content-type: application/xml');
  print($retVal-&gt;asXML());
  </code></pre>