We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8416
    • 173 Posts
    Hello,
    I have an XML representation of some data. I created a XSL to render some HTML view of that data. How can I invoke my XSL to display the HTML code programmatically. I don’t want to add this statement to the XML file since I have more than one XSL file.
    <?xml-stylesheet type="text/xsl" href="MyFile.xsl"?>

    Thanks in advance for your help.

    Eric
      • 2472
      • 151 Posts
      I did an xml to html transformation recently, hope this code example gets you going:

      [tt] ...
      $html= ’’;
      $xp = new XSLTProcessor();

      $xml = new domDocument();
      $xml -> loadXML( utf8_encode( $xmltree));

      $xsl = new domDocument();
      $xsl -> loadXML( $stylesheet);

      $xp -> importStylesheet($xsl);

      $html = $xp -> transformToXml($xml);
      ...
      [/tt]

      You might need to set some php extensions to get things working.
        A thing of beauty is a joy forever ( John Keats)
        • 8416
        • 173 Posts
        Thanks that helps...