In one of my template pages, I'm using PHP to load an XML doc and transform it with XSL. It displays in a Div just fine.
My question is: I want to switch among multiple XSL files that transform this same XML doc. The idea is to let the user click a link that loads the appropriate XSL (to display the data in different ways). I was doing this easily when loading the XML with client-side AJAX, but with PHP, the XML is already rendered when the page loads. It's not dynamic.
I can probably use JavaScript to toggle visibility of multiple Divs, but that seems too processor-intensive. Any ideas?
Here's my PHP that works:
<?php
$processor = new XSLTProcessor;
$xsl = new DOMDocument;
$current_dir = get_bloginfo('template_directory');
$xsl -> load($current_dir . '/xml/myStyles.xsl');
$processor -> importStyleSheet($xsl);
$xml = new DOMDocument;
$xml -> load($current_dir . '/xml/myData.xml');
$result = $processor -> transformToXML($xml);
echo "$result";
?>