title: viewing XML like that of IE on Vista with TWebBrowser
body: <p>On XP this code worked fine if I wanted to view XML in a <code>TWebBrowser</code>:</p>
  
  <pre><code>uses ComObj, MSHTML, ActiveX;
  
  procedure DocumentFromString(ABrowser: TWebBrowser; const HTMLString: wideString);
  var
    v: OleVariant;
    HTMLDocument: IHTMLDocument2;
  begin
    if not Assigned(ABrowser.Document) then
    begin
      ABrowser.Navigate('about:blank');
      while ABrowser.ReadyState &lt;&gt; READYSTATE_COMPLETE do
      begin
        Application.ProcessMessages;
        Sleep(0);
      end;
    end;
    HTMLDocument := ABrowser.Document as IHTMLDocument2;
    v := VarArrayCreate([0, 0], varVariant);
    v[0] := HTMLString;
    HTMLDocument.Write(PSafeArray(TVarData(v).VArray));
    HTMLDocument.Close;
  end;
  
  procedure WebBrowserXML(ABrowser: TWebBrowser; const XmlString: WideString);
  var
    xml, xsl: OleVariant;
    HTMLString: WideString;
  begin
    xml := CreateOleObject('Msxml2.DOMDocument');
    xml.async := False;
    xml.loadXML(XmlString);
    // Assert(xml.parseError.errorCode = 0);
    xsl := CreateOleObject('Msxml2.DOMDocument');
    xsl.validateOnParse := False;
    xsl.async := False;
    xsl.load('res://msxml.dll/defaultss.xsl');
    // Assert(xsl.parseError.errorCode = 0);
    HTMLString := xml.transformNode(xsl);
    ABrowser.HandleNeeded;
    DocumentFromString(ABrowser, HTMLString);
  end;
  
  procedure TForm1.Button1Click(Sender: TObject);
  begin
    WebBrowserXML(WebBrowser1, '&lt;xml&gt;&lt;node&gt;Hello&lt;/node&gt;&lt;/xml&gt;');
  end;
  </code></pre>
  
  <p>The method is as followed: the <strong>XML</strong> is transformed with <strong>XSLT</strong> (<code>defaultss.xsl</code>) and the result is <strong>HTML</strong>.</p>
  
  <p>On Vista I get an exeption in the line <code>xml.transformNode(xsl);</code>:</p>
  
  <blockquote>
    <p>The stylesheet does not caontain a document element. The stylesheet
    may be empty, or it may not be a well-formed XML document</p>
  </blockquote>
  
  <p>I have tried to directly load my own copy of XSLT from file like this <code>xsl.load('my.xsl')</code>:    </p>
  
  <p><a href="http://forums.asp.net/t/1141304.aspx?xslt+viewing+XML+like+that+of+IE" rel="nofollow">http://forums.asp.net/t/1141304.aspx?xslt+viewing+XML+like+that+of+IE</a></p>
  
  <p>but still I get the same error that the XSLT is not valid.</p>
  
  <p>How do I make this code work on Vista?</p>
  
  <hr>
  
  <p>From the comments to the <a href="http://forums.asp.net/t/1141304.aspx?xslt%20viewing%20XML%20like%20that%20of%20IE" rel="nofollow">link</a> I provided:</p>
  
  <blockquote>
    <p>I have also found that after calling directly into
    <strong>res://msxml#.dll/defaultss.xsl</strong> for years, this method no longer works
    in Vista.  I've messed with all sorts of security settings, but that
    does not seem to be the issue. It looks like my only option is to
    release my own copy of defaultss.xsl.</p>
  </blockquote>
  
  <p>I can't seem to provide a valid "my own copy" of <code>defaultss.xsl</code>. they all fail with the same exception error. what can I do?</p>