What are the advantages of using XSLT as a template language in PHP development, and how does it compare to other template engines like Smarty?
Using XSLT as a template language in PHP development allows for separation of presentation and logic, making the code more maintainable and easier to update. XSLT also provides a powerful way to transform XML data into different formats. Compared to other template engines like Smarty, XSLT offers more flexibility and control over the transformation process.
// Example code snippet using XSLT in PHP
$xml = new DOMDocument();
$xml->load('data.xml');
$xsl = new DOMDocument();
$xsl->load('template.xsl');
$proc = new XSLTProcessor();
$proc->importStyleSheet($xsl);
echo $proc->transformToXML($xml);