猫ゾン結果なんだけど……ちといい方法考えてる、XMLファイルをそのまま表示できるのがあるはず…
私はこういうのでやっています。
アマゾンからダウンロードしたxmlの先頭二行をこういう風に変更して下のxslファイルと同じとこにおくだけです。
<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="xmltemplate.xsl"?><Data><Report><Caption>すきなキャプション</Caption></Report> <Items>
xmltemplate.xsl
<?xml version="1.0" encoding="Shift_JIS"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head> <title>好きなタイトル</title> <link rel="stylesheet" type="text/css" href="CSSを使うところ" /> </head> <body> <p align="center">適当なことを書くところ<br/> </p> <table> <tr> <th> 商品画像 </th> <th> タイトル </th> <th> 価格 </th> <th> 発送済み商品数 </th> <th> 紹介料率% </th> <th> 発送された商品の売上 </th> <th> 紹介料合計 </th> </tr> <xsl:apply-templates /> </table> </body> </html> </xsl:template> <xsl:template match="Report"> <caption> <xsl:value-of select="Caption" /> </caption> </xsl:template> <xsl:template match="Items"> <xsl:for-each select="Item"> <xsl:sort select="@Binding" order="ascending"/> <xsl:sort select="@Title" order="ascending"/> <tr height="75"> <td class="pic"> <a class="pic"> <xsl:attribute name="href"> <xsl:value-of select="concat('http://www.amazon.co.jp/exec/obidos/ASIN/',@ASIN,'/あんたのアフィリエイトID/')" /> </xsl:attribute> <img border="0"> <xsl:attribute name="src"> <xsl:value-of select="concat('http://images-jp.amazon.com/images/P/',@ASIN,'.09.THUMBZZZ.jpg')" /> </xsl:attribute> </img> </a> </td> <td class="title"> <a> <xsl:attribute name="href"> <xsl:value-of select="concat('http://www.amazon.co.jp/exec/obidos/ASIN/',@ASIN,'/あんたのアフィリエイトID/')" /> </xsl:attribute> <xsl:value-of select="@Title" /> </a> <br /> <span class="binding"> <xsl:value-of select="@Binding" /> </span> </td> <td> <xsl:value-of select="@Price" /> </td> <td> <xsl:value-of select="@Qty" /> </td> <td> <xsl:value-of select="@Rate" /> </td> <td> <xsl:value-of select="@Revenue" /> </td> <td> <xsl:value-of select="@Earnings" /> </td> </tr> </xsl:for-each> </xsl:template> <xsl:template match="AMZNShipmentTotals"> <tr> <td colspan ="2" class="ttlhd"> 発送済み商品の合計(Amazon.co.jp) </td> <td class="ttl"> </td> <td class="ttl"> <xsl:value-of select="Units" /> </td> <td class="ttl"> <xsl:value-of select="@Rate" /> </td> <td class="ttl"> <xsl:value-of select="Revenue" /> </td> <td class="ttl"> <xsl:value-of select="Earnings" /> </td> </tr> </xsl:template> <xsl:template match="NonAMZNShipmentTotals"> <tr> <td colspan="2" class="ttlhd"> 発送済み商品の合計(マーケットプレイス) </td> <td class="ttl"> </td> <td class="ttl"> <xsl:value-of select="Units" /> </td> <td class="ttl"> <xsl:value-of select="@Rate" /> </td> <td class="ttl"> <xsl:value-of select="Revenue" /> </td> <td class="ttl"> <xsl:value-of select="Earnings" /> </td> </tr> </xsl:template> <xsl:template match="ShipmentTotals"> <tr> <td colspan="2" class="ttlhd"> 発送済み商品合計 </td> <td class="ttl"> </td> <td class="ttl"> <xsl:value-of select="Units" /> </td> <td class="ttl"> <xsl:value-of select="@Rate" /> </td> <td class="ttl"> <xsl:value-of select="Revenue" /> </td> <td class="ttl"> <xsl:value-of select="Earnings" /> </td> </tr> </xsl:template> <xsl:template match="ReturnedTotals"> <tr> <td colspan="2" class="ttlhd"> 返品数合計 </td> <td class="ttl"> </td> <td class="ttl"> <xsl:value-of select="Units" /> </td> <td class="ttl"> <xsl:value-of select="@Rate" /> </td> <td class="ttl"> <xsl:value-of select="Revenue" /> </td> <td class="ttl"> <xsl:value-of select="Earnings" /> </td> </tr> </xsl:template> <xsl:template match="RefundedTotals"> <tr> <td colspan="2" class="ttlhd"> 返金合計 </td> <td class="ttl"> </td> <td class="ttl"> <xsl:value-of select="Units" /> </td> <td class="ttl"> <xsl:value-of select="@Rate" /> </td> <td class="ttl"> <xsl:value-of select="Revenue" /> </td> <td class="ttl"> <xsl:value-of select="Earnings" /> </td> </tr> </xsl:template> <xsl:template match="ReferralFeeTotals"> <tr> <td colspan="2" class="ttlhd"> 紹介料合計 </td> <td class="ttl"> </td> <td class="ttl"> <xsl:value-of select="Units" /> </td> <td class="ttl"> <xsl:value-of select="@Rate" /> </td> <td class="ttl"> <xsl:value-of select="Revenue" /> </td> <td class="ttl"> <xsl:value-of select="Earnings" /> </td> </tr> </xsl:template> <xsl:template match="ProductLine_array"> </xsl:template> <xsl:template match="FinalEarnings"> </xsl:template> <xsl:template match="Bonuses"> </xsl:template> <xsl:template match="FinalEarnings"> </xsl:template> </xsl:stylesheet>
これはおまけ
このphpに?period='amazonからダウンロードしたxmlファイルのファイル名'としてます。
<?php header("Content-Type:text/html;charset=UTF-8"); $strDir=dirname(__FILE__); $strXml=$strDir."/".$_GET['period'].".xml"; if (file_exists($strXml)){ $strXsl=$strDir."/xmltemplate.xsl"; $objPrc=xslt_create(); $result=xslt_process($objPrc,$strXml,$strXsl); print($result); } else { print "requested data ".$_GET['period']." not found."; } ?>
これもおまけのcss
body { font-size:12px; font-family: arial,sans-serif; font-weight:100; } a { text-decoration:none; cursor:pointer; background-color:transparent } a:link { color:#333353 } a:visited { color:#883030 } a:active { color:#004040 } a:hover { color:#ffffff; background-color: #aaaadd;} a img { border: none } a.pic:hover { background-color: #eeeefe;} table { width:95%; text-align: center; border-style: solid; border-width: 1px; border-color: #aaaadd; border-collapse: collapse; background-color:#dddddd; } th { font-size:12px; color: #777797; border-style: solid; border-width: 1px; border-collapse: collapse; border-color: #aaaadd; background-color:#ccccec; padding-top:4px; padding-bottom:4px; } td { border-style: solid; border-width: 1px; border-collapse: collapse; border-color: #aaaadd; background-color:#eeeefe; color:#555575; padding:8px; text-align:right; } td.pic { text-align:center; padding:0px; } td.title { text-align:left } td.ttlhd { text-align:left; padding:2px; } td.ttl { padding:2px; } span.binding {font-size:10px; font-color:#999999; font-style:italic; } caption { text-align:left; color:#555575; }