[英]converting .doc and .xls file to html on rhel 4 server using php
[英]Converting XML to HTML - Using PHP and XLS template
我有這個非常簡單的代碼,應該可以為我生成HTML,但是我得到的只是白頁。 我嘗試了幾乎所有內容,只是空白頁。 如果有人可以檢查並告訴我我做錯了什么,那我將成為天堂!
PHP代碼:
$xp = new XsltProcessor();
// create a DOM document and load the XSL stylesheet
$xsl = new DomDocument;
$xsl->load('template-file.xls');
// import the XSL styelsheet into the XSLT process
$xp->importStylesheet($xsl);
// create a DOM document and load the XML datat
$xml_doc = new DomDocument;
$xml_doc->load('temporary-file.xml');
// transform the XML into HTML using the XSL file
if ($html = $xp->transformToXML($xml_doc)) {
return $html;
} else {
return "<p>FAILED</p>";
}
XML檔案:
<?xml version="1.0"?>
<results>
<xml_report>
<subject>
<efx_file_header>
<efx_header>
<bureau>EFX</bureau>
<customer_number>682ZB08042</customer_number>
<customer_reference_code>199</customer_reference_code>
<ecoa>2</ecoa>
<output_format>02</output_format>
<multiple_files_indicator>1</multiple_files_indicator>
<name>ZUVICH, TYLER J</name>
<ssn>196722017</ssn>
</efx_header>
</efx_file_header>
</subject>
</xml_report>
</results>
這是XLS模板文件:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:php="http://php.net/xsl"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Edited by Adrian -->
<xsl:output method="html" encoding="UTF-8" indent="yes"/>
<xsl:template match="results/xml_report">
<xsl:for-each select="subject">
<table class="table-paddings" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="245px">Boreau</td>
<td width="250px"><xsl:value-of select="efx_file_header/ext_header/bureau" /></td>
</tr>
<tr>
<td>Customer Number</td>
<td><xsl:value-of select="efx_file_header/ext_header/customer_number" /></td>
</tr>
<tr>
<td>Customer Reference Code</td>
<td><xsl:value-of select="efx_file_header/ext_header/customer_reference_code" /></td>
</tr>
</tbody>
</table>
<br />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
嘗試echo $html
而不是return $html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.