I am currently converting an XML document with an XSLT stylesheet using Javascript (on the Wordpress website). This works fine in Firefox and Chrome, but not in IE. Also, if Javascript is not enabled, nothing will appear.
So my goal is to convert XML / XSLT to XHTML on the server, not the client, preferably using PHP.
I have tried many different PHP scripts written by other people (I am new), but I cannot get them to work. I included the simplest PHP script I found below. I know that a dynamic file path can be a problem, but I donโt know how best to find the XML and XSLT files.
When I use the script below, I get the error: Syntax error: syntax error, unexpected T_STRING in / home / alan / public _html / wp-content / themes / Stacked / page-renting.php on line 42
Alternative solutions are also welcome.
<?php $xml = new DOMDocument(); $xml->load('<?php bloginfo('template_directory'); ?>/rentals/works.xml'); $xsl = new DOMDocument; $xsl->load('<?php bloginfo('template_directory'); ?>/rentals/works.xsl'); $proc = new XSLTProcessor(); $proc->importStyleSheet($xsl); echo $proc->transformToXML($xml); ?>
source share