IXMLHttpRequest.responseXml está vacío, sin error de análisis, cuando responseText contiene Xml @ váli

Estoy obteniendo algo de XML deun sitio web del gobierno:

http://www.bankofcanada.ca/stats/assets/rates_rss/noon/en_all.xml

Estoy usando el siguiente código bastante simple:

var
   szUrl: string;
   http: IXMLHTTPRequest;
begin
   szUrl := 'http://www.bankofcanada.ca/stats/assets/rates_rss/noon/en_all.xml';

   http := CoXMLHTTP60.Create;
   http.open('GET', szUrl, False, '', '');
   http.send(EmptyParam);

   Assert(http.Status = 200);

   Memo1.Lines.Add('HTTP/1.1 '+IntToStr(http.status)+' '+http.statusText);
   Memo1.Lines.Add(http.getAllResponseHeaders);
   Memo1.Lines.Add(http.responseText);

i no mostrará todo el cuerpo que devuelve, pero devuelve un xml válido enresponseText:

HTTP/1.1 200 OK
Cache-Control: max-age=5
Connection: keep-alive
Connection: Transfer-Encoding
Date: Fri, 30 Mar 2012 14:50:50 GMT
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
Expires: Fri, 30 Mar 2012 14:50:55 GMT
Server: Apache/2.2.16 (Unix) PHP/5.3.3 mod_ssl/2.2.16 OpenSSL/1.0.0d mod_perl/2.0.4 Perl/v5.12.0
X-Powered-By: PHP/5.3.3


<?xml version="1.0" encoding="ISO-8859-1"?>
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns="http://purl.org/rss/1.0/"
    xmlns:cb="http://www.cbwiki.net/wiki/index.php/Specification_1.1"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:dcterms="http://purl.org/dc/terms/"
    xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.w3c.org/1999/02/22-rdf-syntax-ns#rdf.xsd">
    <channel rdf:about="http://www.bankofcanada.ca/stats/assets/rates_rss/noon/en_ALL.xml">
        <title xml:lang="en">Bank of Canada: Noon Foreign Exchange Rates</title>
        <link>http://www.bankofcanada.ca/rates/exchange/noon-rates-5-day/</link>

Está bien, está bien, hay xml válido allí. Sé que es válido porque ... bueno, míralo. Pero también sé que es válido analizándolo:

var
   ...
   szXml: WideString;
   doc: DOMDocument60;
begin
   ...
   szXml := http.responseText;

   doc.loadXML(szXml);
   Assert(doc.parseError.errorCode = 0);

   Memo1.Lines.Add('============parsed xml');
   Memo1.Lines.Add(doc.xml);

The origianalIXmlHttpRequest contiene unaresponseXml propiedad. Desde MSDN:

epresenta el cuerpo de la entidad de respuesta analizad

Si el cuerpo de la entidad de respuesta no es XML válido, esta propiedad devuelve DOMDocument que se analizó para que pueda acceder al error. Esta propiedad no devuelve IXMLDOMParseError en sí, pero es accesible desde DOMDocument.

En mi caso, la propiedad responseXml existe, como debería:

Assert(http.responseXml <> nil);

Y no hay un error de análisis de respuesta Texto:

doc := http.responseXml as DOMDocument60;
Assert(doc.parseError.errorCode = 0);

como debería haber, ya que el xml es válido.

Excepto que cuando miro elhttp.responseXml objeto de documento, está vacío:

   Memo1.Lines.Add('============responseXml');
   Memo1.Lines.Add(doc.xml);

Is es IXMLHttpRequest (y IXMLServerHttpRequest) que devuelve un documento XML vacío, cuando:

hay xmlthe xml es válido no hay error de análisis

En forma larga:

uses
    msxml2_tlb;

procedure TForm1.Button1Click(Sender: TObject);
var
    szUrl: string;
    http: IXMLHTTPRequest;
    doc: DOMDocument60;
begin
    szUrl := 'http://www.bankofcanada.ca/stats/assets/rates_rss/noon/en_all.xml';

    http := CoXMLHTTP60.Create; //or CoServerXmlHttpRequest.Create
    http.open('GET', szUrl, False, '', '');
    http.send(EmptyParam);

    Assert(http.Status = 200);

    doc := http.responseXml as DOMDocument60;
    Assert(doc.parseError.errorCode = 0);

    ShowMessage('"'+doc.xml+'"');
end;

¿Cómo hagoXmlHttpRequest (y más importanteServerXMLHTTP60) comportarse como está documentado?

Respuestas a la pregunta(8)

Su respuesta a la pregunta