note 36023 added to function.domxml-xslt-stylesheet
| From: | domxml_xslt_stylesheet_file at rn2 dot php dot net | Date: | Tue, 23 Sep 2003 11:16:06 +0000 |
| Subject: | note 36023 added to function.domxml-xslt-stylesheet | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-56960@lists.php.net to get a copy of this message | ||
You can also do it like this:
sample.php
----------------
<?php
//Transformer XML -> HTML par XSL
$CurrentDir = dirname(__FILE__);
$xmldoc = domxml_open_file("$CurrentDir\\sample.xml");
$xsldoc = domxml_xslt_stylesheet_file("$CurrentDir\\sample.xsl");
$result = $xsldoc->process($xmldoc);
print $xsldoc->result_dump_mem($result);
?>
sample.xml
---------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
<autor>
<name>Autor Name</name>
<adress>Adress</adress>
<postal>postalcode</postal>
<city>City</city>
</autor>
</catalog>
sample.xsl
-------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited with XML Spy v4.2 -->
<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="0">
<tr bgcolor="#9acd32">
<th align="left">Title</th>
<th align="left">Artist</th>
<th align="left">Price</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
<td><xsl:value-of select="price"/></td>
</tr>
</xsl:for-each>
</table>
<br/>
<br/>
<br/>
<br/>
<table border="0">
<xsl:for-each select="catalog/autor">
<tr>
<th align="left">Autor of site</th>
</tr>
<tr>
<td><xsl:value-of select="name"/></td>
</tr>
<tr>
<td><xsl:value-of select="adress"/></td>
</tr>
<tr>
<td><xsl:value-of select="postal"/></td>
</tr>
<tr>
<td><xsl:value-of select="city"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
----
Manual Page -- http://www.php.net/manual/en/function.domxml-xslt-stylesheet.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36023
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36023&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36023&report=yes