たくさんのことを試しましたが、画面に何もロードできません。PHP は問題なく XML を画面にロードしますが、PHP に XSL コードを追加すると、画面は空白になり、エラーも何も表示されません。誰でも理由がわかりますか?
ありがとうございました
PHP ファイル:
<?php
$doc = new DOMDocument();
$doc->load( 'books.xml' );
$xsl = new DOMDocument;
$xsl->load( 'books.xsl' );
$books = $doc->getElementsByTagName( "book" );
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
foreach( $books as $book )
{
$authors = $book->getElementsByTagName( "author" );
$author = $authors->item(0)->nodeValue;
$publishers = $book->getElementsByTagName( "publisher" );
$publisher = $publishers->item(0)->nodeValue;
$titles = $book->getElementsByTagName( "title" );
$title = $titles->item(0)->nodeValue;
echo $proc->transformToXML($doc);
// echo "$title - $author - $publisher\n";
}
?>
XML ファイル:
<?xml version="1.0" encoding="ISO-8859-1"?>
<books>
<book>
<author>Jack Herrington</author>
<title>PHP Hacks</title>
<publisher>O'Reilly</publisher>
</book>
<book>
<author>Jack Herrington</author>
<title>Podcasting Hacks</title>
<publisher>O'Reilly</publisher>
</book>
</books>
XSL ファイル:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>author</th>
<th>title</th>
<th>publisher</th>
</tr>
<xsl:for-each select="books/book">
<tr>
<td><xsl:value-of select="author"/></td>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="publisher"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>