marozen
Member
Loading a webpage can take a lot of time if values are loaded with php from, a large database table. I want to add php code that transforms the loaded page into a XML file. And then with XSL files you can make the page look like a HTML page. And loading it will be much faster and the file can also be loaded at other websites like an RSS-feed.
The code in the default.php template is as followed:
$xml = new DOMDocument("1.0","UTF-8");
$xml->substituteEntities = true;
$stylesheet = new DOMDocument;
$stylesheet->substituteEntities = true;
if ($stylesheet->load("https://rozendale.com/th/rad/plants.xsl") == false)
die('Failed to load XSLT file');
$xml->formatOutput=true;
$root=$xml->createElement('root');
$root->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
$root->setAttribute('xsi:noNamespaceSchemaLocation', "https://rozendale.com/th/rad/plants.xsd");
$xml->appendChild($root);
$title=$xml->createElement("title", $title);
$root->appendChild($title);
$body=$xml->createElement("body", $body);
$root->appendChild($body);
echo "<xmp>".$xml->saveXML()."</xmp>";
$xml->save("https://rozendale.com/th/rad/p$id.xml") or die("Error,Unable to create XML");
The result is an XML file with $body as an element with the entire html output of the template.
Are there easier ways to safe the page loadings in HTML or XML and to load them quicker?
The code in the default.php template is as followed:
$xml = new DOMDocument("1.0","UTF-8");
$xml->substituteEntities = true;
$stylesheet = new DOMDocument;
$stylesheet->substituteEntities = true;
if ($stylesheet->load("https://rozendale.com/th/rad/plants.xsl") == false)
die('Failed to load XSLT file');
$xml->formatOutput=true;
$root=$xml->createElement('root');
$root->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
$root->setAttribute('xsi:noNamespaceSchemaLocation', "https://rozendale.com/th/rad/plants.xsd");
$xml->appendChild($root);
$title=$xml->createElement("title", $title);
$root->appendChild($title);
$body=$xml->createElement("body", $body);
$root->appendChild($body);
echo "<xmp>".$xml->saveXML()."</xmp>";
$xml->save("https://rozendale.com/th/rad/p$id.xml") or die("Error,Unable to create XML");
The result is an XML file with $body as an element with the entire html output of the template.
Are there easier ways to safe the page loadings in HTML or XML and to load them quicker?