Speed up development with full-stack environments for every branch.

Learn More

How to transform XML to HTML using PHP [XSL and XSLT]

863 Runs 5003 Views 2394 Copies
Saved

Saved

gtsolutions 373

gtsolutions
published 4 years ago

<?php

/*
 * PHP XSL - How to transform XML to HTML using PHP
 */

// Load the XML source
$xml = new DOMDocument;
$xml->load('data/collection.xml');

$xsl = new DOMDocument;
$xsl->load('data/collection.xsl');

// Configure the transformer
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules

$proc->transformToURI($xml, 'file:///var/www/data/out.html');

echo file_get_contents('data/out.html');
?>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).