As the title says, I'm trying to transform an XML file using XSL at the server. My XML file saves to the server and displays fine. However if I try transforming it, nothing displays. Here is the code in question.
XML.PHP
<?php
header ("Content-Type:text/xml");//Tell browser to expect xml
include ("config/init.php");
$connection = mysqli_connect($hostname, $username, $password, $databaseName) or die("you did not connect");
$query = "SELECT * FROM art";
$result = mysqli_query($connection, $query) or die (mysqli_error($connection));
//Top of xml file
$_xml = '<?xml version="1.0"?>';
$_xml .="<art>";
while($row = mysqli_fetch_array($result)) {
$_xml .="<art>";
$_xml .="<art_name>".$row['name']."</art_name>";
$_xml .="<art_category>".$row['category']."</art_category>";
$_xml .="<art_price>".$row['price']."</art_price>";
$_xml .="</art>";
}
$_xml .="</art>";
//Parse and create an xml object using the string
$xmlobj=new SimpleXMLElement($_xml);
//And output
//print $xmlobj->asXML();
//or we could write to a file
$xmlobj->asXML('art.xml');
?>
XSL.PHP
<?php require 'header.php';?>
<div class="sixteen columns">
<?php
//Create a DomDocument object
$xml = new DOMDocument;
// Load the XML source
$xml -> load('art.xml');
//Similar with XSL
$xsl = new DOMDocument;
$xsl -> load('art.xsl');
// Create and Configure the transformer
$proc = new XSLTProcessor;
// attach the xsl rules
$proc -> importStyleSheet($xsl);
//Output
echo $proc -> transformToXML($xml);
?>
</div>
<?php require 'footer.php'; ?>
EDIT
aplogies about the late reply. When saved, the XML file now holds data. Here is are the files as requested.
art.xml
<?xml version="1.0"?>
<art><art><art_name>Game Weapons</art_name><art_category>Weapons</art_category><art_price>11</art_price></art><art><art_name>Violet</art_name><art_category>Scenery</art_category><art_price>11</art_price></art><art><art_name>Wolf</art_name><art_category>Character</art_category><art_price>11</art_price></art><art><art_name>A Calvert</art_name><art_category>Character</art_category><art_price>11</art_price></art><art><art_name>Scatter Character</art_name><art_category>Character</art_category><art_price>11</art_price></art><art><art_name>Bonfire</art_name><art_category>Scenery</art_category><art_price>11</art_price></art><art><art_name>Clouds</art_name><art_category>Scenery</art_category><art_price>11</art_price></art><art><art_name>Dawn</art_name><art_category>Scenery</art_category><art_price>11</art_price></art><art><art_name>Face</art_name><art_category>Character</art_category><art_price>11</art_price></art><art><art_name>Scarra</art_name><art_category>Character</art_category><art_price>11</art_price></art><art><art_name>Scatter World</art_name><art_category>Scenery</art_category><art_price>11</art_price></art><art><art_name>Woods</art_name><art_category>Scenery</art_category><art_price>11</art_price></art><art><art_name>f</art_name><art_category>f</art_category><art_price>2</art_price></art></art>
art.xsl
<!-- Edited with XML Spy v4.2 -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<h2>Art</h2>
<table border="1">
<tr bgcolor="#333">
<th align="left" style="padding:0 0 0 20px;"><font color="#FFF">Name</font></th>
<th align="left" style="padding:0 0 0 15px;"><font color="#FFF">Category</font></th>
<th align="left" style="padding:0 0 0 5px;"><font color="#FFF">Price</font></th>
</tr>
<xsl:for-each select="art/art">
<tr>
<td style="padding:10px 15px 10px 0;">
<xsl:value-of select="art_name"/>
</td>
<td style="padding:10px 15px 10px 15px;">
<xsl:value-of select="art_category"/>
</td>
<td style="padding:10px 15px 10px 15px;">
<xsl:value-of select="art_price"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
EDIT
Turns out there was noting wrong with the code. The server has XSL disabled....working now. Thanks for the help