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

Learn More

How to transform XML to a DOMDocument using PHP [XSL and XSLT]

26 Runs 138 Views 25 Copies
Saved

Saved

gtsolutions 373

gtsolutions
published 4 years ago

<pre>
<?php

/*
 * PHP XSL - How to transform XML to a DOMDocument 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');

var_dump($proc->transformToDoc($xml));
?>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).