Skip to content

Instantly share code, notes, and snippets.

@lbrutti
Created October 24, 2018 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbrutti/7c366198cb2556bfe723fa961cf47fd0 to your computer and use it in GitHub Desktop.
Save lbrutti/7c366198cb2556bfe723fa961cf47fd0 to your computer and use it in GitHub Desktop.
a simple php script to apply an XSLT to an XML file
<?php
if (count($argv) == 0) {
exit;
}
$xsltPath = $argv[1];
$xmlPath = $argv[2];
// $outputPath = $argv[3];
$xslt = file_get_contents($xsltPath);
$xml = file_get_contents($xmlPath);
$templateCMSObj = new \DOMDocument();
$templateCMSObj->loadXML($xslt);
$ekbXMLObj = new \DOMDocument();
$ekbXMLObj->loadXML($xml);
$proc = new \XSLTProcessor();
$proc->importStylesheet($templateCMSObj);
$html = $proc->transformToXML($ekbXMLObj);
echo($html);
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment