不知道在delphi中怎样把xml和xsl文件直接转换成.html的游览文件,请高手指点。 

解决方案 »

  1.   

    uses MSXML;
    ....function XML2HTML(xmlfilePath, xslfilePath, htmlfilepath: string): boolean;
    var
       xmlDom, xslDom: IXMLDOMDocument;
       htmlContent: widestring;
       tmpList: TStringList;
    begin
       xmlDom := CoDOMDocument.Create;
       xslDom := CoDOMDocument.Create;
       xmlDom.async := false;
       xslDom.async := false;
       tmpList := TStringList.Create;
       try
          xmlDom.load(xmlfilepath);
          xslDom.load(xslfilepath);
          htmlcontent := xmlDom.transformNode(xslDom);
          tmpList.Add(htmlcontent);
          tmpList.SaveToFile(htmlfilepath);
          tmpList.Clear;
          result := true;
       finally
          xmlDom := nil;
          xslDom := nil;
          tmpList.Free;
       end;
    end;
      

  2.   

    如果你使用的不是msxml(就象上面),而是其它一些xml包的话应该也有类似的代码来实现的