TechniqueMake sure that you have compiled PHP with Sablotron XSL support. Then you can use the xslt_transform() function: <?php if (!xslt_transform($stylesheet, $xmlfile, "arg:/result" 0, 0, $result)) { die(sprintf('Error [%d]: %s', xslt_errno(), xslt_error())); } print "The transformed document looks like:\n<br>\n"; print $result; ?> CommentsXSL is a language that enables you to describe how structured XML will be displayed. In the synopsis, we take an XML document ( $xmlfile ) and we transform it through a XSL stylesheet ( $stylesheet ). The third and fourth arguments to xslt_transform() are any optional parameters (third argument), and any arguments that you would have to the XSL processor (fourth argument). The arguments, parameters, and function arguments should be associative arrays in the format "argument_name" => "argument_value" . Examine the following, which specifies the document's output to a file instead of a buffer: <?php $args = array("/_outputfile" => "test.html"); if (!xslt_transform($stylesheet, $xslfile, "arg:/_outputfile", 0, $args)) { die(sprintf('Error [%d]: %s', xslt_error(), xslt_errno())); } print "Transformation saved in test.html"; ?> |