I have some code in PHP which I need to translate into Delphi:

$xsl = new DOMDocument();
$xsl->load('http://www.fda.gov/oc/datacouncil/stylesheets/spl/spl.xsl');
$proc = new XSLTProcessor();
$proc->importStylesheet($xsl);
$xml = new DOMDocument();
$xml->load($xmlFile);
$domTranObj = $proc->transformToDoc($xml);
$strHTML = $domTranObj->saveHTML();

What I need to do is take a snippet of XML (from a database field), transform it using the .xsl translation document, and then save the whole thing back into the data field as HTML.

Does anyone know how to do this in Delphi?

I'm getting closer! It looks like Delphi uses the XSLPageProducer to transform XML using an XSL file. However, the result I'm getting is translated text, but without any of the html tags! My code so far:

XSLPageProducer1.Active := False;
XSLPageProducer1.FileName := 'spl.xsl';
strXML := ADOTable1.FieldByName('Field1').Value;
if (strXML <> '') and not (strXML = null) then begin
  XMLDocument1.LoadFromXML(strXML);
  XSLPageProducer1.XMLData := XMLDocument1;
  XSLPageProducer1.Active := True;
  ShowMessage(XSLPageProducer1.Content);
  ADOTable1.Edit;
  ADOTable1.FieldByName('Field1').Value := XSLPageProducer1.Content;
  ADOTable1.Post;
end;

Any ideas why I'm not getting any html tags?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.