Answer the question
In order to leave comments, you need to log in
Generating xml file with included xslt table without XsltProcessor php?
The usual generation mechanism using xslt_processor is:
$template_out = '<?xml version="1.0" encoding="UTF-8"?>';<br/>
$template = file_get_contents($template);<br/>
$proc = new XsltProcessor;<br/>
$xmlDoc = new DomDocument;<br/>
$xslDoc= new DomDocument;<br/>
$xmlDoc->loadXML($template_out);<br/>
$xslDoc->loadXML($template);<br/>
$proc->importStyleSheet($xslDoc);<br/>
$result = $proc->transformToXML($xmlDoc);
$template_out = '<?xml version="1.0" encoding="UTF-8"?><br/>
<?xml-stylesheet href="default.xsl" type="text/xsl" ?>';<br/>
echo $template_out;
$template = 'path/to/xsl-stylesheet';<br/>
$xsl = new DomDocument();<br/>
$xsl->load($template);<br/>
$inputDom = new DomDocument();<br/>
$inputDom->loadXML($template_out);<br/>
$inputDom->formatOutput = true;<br/>
$proc = new XsltProcessor();<br/>
$xsl = $proc->importStylesheet($xsl);<br/>
$newDom = $proc->transformToDoc($inputDom);<br/>
print $newDom->saveXML();
Answer the question
In order to leave comments, you need to log in
As it is not very clear the essence of the issue. If you mean that your script is displayed in the browser as HTML and not as XML, then you need to specify the text/xml content type in the header:
header("Content-type: text/xml");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question