Reputation: 392
How to display all XML files in one folder? These files will be placed in a subfolder called "files" with the same structure and name, chapter-1.xml, chapter-2.xml e.g.
I'm thinking a PHP loop to display the content of each file, but the files are styled with both XSL-document and a CSS-document.
Is there any way to achieve this? Can you bind the XSL and CSS-document in the PHP-file, and then print the content of the XML documents with the styling and rules of the XSL-document?
Upvotes: 1
Views: 1301
Reputation: 1250
Output of an XML-file requires just 3 lines of PHP code (and the XML file with proper XSL Transformation script for HTML output, of course):
<?php
$proc=new XsltProcessor;
$proc->importStylesheet(DOMDocument::load("test.xsl")); //load XSL script
echo $proc->transformToXML(DOMDocument::load("test.xml")); //load XML file and echo
?>
You can pick the file names and wrap an loop around it with usual PHP code. The example comes from my answer for XML Outputting - PHP vs JS vs Anything Else?
Upvotes: 3