Parsing XML with XSLT in Wordpress
Wordpress has a built-in XML processor that may be simpler to use if you're end-goal is to display the content.
If it's easier to include a PHP script that you wrote to convert the feeds or import a library, you can put the script in the theme's folder (i.e. /wp-content/themes/pagelines/) and call it with include_once:
include_once(get_template_directory().'/FILENAME.php');
For using a parameter(get) in a php script use this:
$xmlFile = $_GET['xml-file'];
And then just change your code to something like this:
<?php$xmlFile = $_GET['xml-file'];$xmlDir ='dirWithXmlFiles/';$xmlUri = $xmlDir . $xmlFile;if(! file_exists($xmlUri)){ echo 'some error'; return;}// Load the XML source$xml = new DOMDocument;$xml->load($xmlUri);$xsl = new DOMDocument;$xsl->load('stylesheet.xsl');// Configure the transformer$proc = new XSLTProcessor;$proc->importStyleSheet($xsl); // attach the xsl rulesecho $proc->transformToXML($xml);
And if you need to add some dynamic content, you can do that by either passing parameters like this:
$proc->setParam('someNameOfParameter', $someValueOfParameter);
and use that in the xslt, or build a xml file with content of $xmlUri and the dynamic content as xml.