How can an XML file display in a TWebBrowser in the ?collapsible? format like Internet Explorer?

Abstract: How can an XML file display in a TWebBrowser in the ?collapsible? format like Internet Explorer?

  • Product Name: Delphi
  • Product Version: Any Win32 VCL
  • Product Component: TWebBrowser
  • Platform/OS Version: Win32

Description:

How can an XML file display in a TWebBrowser in the ?collapsible? format like Internet Explorer?


Answer/Solution:

The problem with displaying an XML file in the TWebBrowser is that the XML gets parsed, rather than having the internal XSL style sheet applied to convert XML for display, as Internet Explorer does.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

procedureDisplayXMLTreeShort(ABrowser : TWebBrowser; EditedXMLDoc : TXMLDocument);

var

�� HTMLDoc : Variant;

�� XMLDoc: IXMLDOMDocument;

�� XSLDoc: IXMLDOMDocument;

begin��

ABrowser.Navigate('about:blank');�

HTMLDoc := ABrowser.Document;

if not VarIsNull(HTMLDoc) then

begin��

��� XSLDoc :=CoDOMDocument.Create; //uses MSXML

��� if XSLDoc.load('res://msxml.dll/defaultss.xsl')then

��� begin

������� XMLDoc := CoDOMDocument.Create;�

������� EditedXMLDoc.Active := true;

������� if XMLDoc.loadXML(EditedXMLDoc.xml.Text) then HTMLDoc.write(XMLDoc.transformNode(XSLDoc));

������� HTMLDoc.Close;���

��� end;

end;

end;

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


Author: Roy Nelson