Created
March 22, 2012 21:42
-
-
Save bzerangue/2164783 to your computer and use it in GitHub Desktop.
PHP: XSLT Transformation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// You instantiating the XSLTProcessor - libXSLT | |
$xmlProc = new XsltProcessor(); | |
// Your XSLT Stylesheet for transforming XML | |
$xslt = new DomDocument(); | |
$xslt -> load("example.xsl"); | |
// This prepares the XSLT for transform | |
$xmlProc -> importStylesheet($xslt); | |
// This is your source XML document | |
$xml = new DomDocument(); | |
$xml -> load("http://domain.com/example.xml"); | |
// Run Tranform and output XML/HTML | |
if ($output = $xmlProc -> transformToXML($xml)) | |
{ | |
echo $output; | |
} | |
// If the transform fails, then it will output this statement below | |
else | |
{ | |
echo "<p>This feed is not available.</p>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment