[XSLT][DOM] Php - Xml - Xsl
Bonjour,
je n'arrive pas a recuperer les infos de mon fichier XML.
XML :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
<?xml version="1.0" encoding="utf-8"?>
<SEGMENTS>
<SEGMENT NAME="webcluster">
<RESULTPAGE>
<QUERYTRANSFORMS><QUERYTRANSFORM NAME="Original query" ACTION="NOP" QUERY="michelin" CUSTOM="" MESSAGE="Original query" MESSAGEID="1"/>
<QUERYTRANSFORM NAME="FastQT_DefaultIndex" ACTION="Suggested new query" QUERY="lemcontent:michelin" CUSTOM="" MESSAGE="Default index suggested for textual terms in the query" MESSAGEID="2"/>
</QUERYTRANSFORMS>
<NAVIGATION ENTRIES="0">
</NAVIGATION>
<CLUSTERS></CLUSTERS>
<RESULTSET FIRSTHIT="1" LASTHIT="10" HITS="10" TOTALHITS="84" MAXRANK="5097" TIME="0.0000">
<HIT NO="1" RANK="2223" SITEID="0" MOREHITS="0">
<FIELD NAME="rank">2223</FIELD>
<FIELD NAME="internalid">dabb9488a8d2574e45aa154b37148eaa_Newsletter</FIELD>
<FIELD NAME="contentid">http://localhost/STR_NEWS_HTML_2004/20040517/20040517_1.html</FIELD>
<FIELD NAME="contentids">http://localhost/STR_NEWS_HTML_2004/20040517/20040517_1.html</FIELD>
</HIT>
<HIT NO="2" RANK="2223" SITEID="0" MOREHITS="0">
<FIELD NAME="rank">2223</FIELD>
<FIELD NAME="internalid">ccec9c35587b62010c0d14d72b74b62c_Newsletter</FIELD>
<FIELD NAME="contentid">http://localhost/STR_NEWS_HTML_1999/19990325/19990325_3.html</FIELD>
<FIELD NAME="contentids">http://localhost/STR_NEWS_HTML_1999/19990325/19990325_3.html</FIELD>
</HIT>
</RESULTSET>
<PAGENAVIGATION>
<NEXTPAGE FIRSTHIT="11" LASTHIT="20" URL=""/>
</PAGENAVIGATION>
</RESULTPAGE>
</SEGMENT>
</SEGMENTS> |
XSL :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="no"/>
<xsl:template match="/">
<html>
<head>
<meta name="author" content="orion"/>
<style type="text/css">
.bg-0 { background-color: #efefff; }
.bg-1 { background-color: #efffef; }
</style>
</head>
<body bgcolor="white" text="black">
<table><xsl:apply-templates match="SEGMENTS"/></table>
</body>
</html>
</xsl:template>
<xsl:template match="SEGMENTS">
<xsl:for-each select="RESULTSET">
<xsl:for-each select="HIT">
<tr class="bg-{position() mod 2}">
<td>FIELD: <xsl:value-of select="FIELD"/></td>
</tr>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet> |
PHP :
Code:
1 2 3 4 5 6 7
|
<?php
$xml = domxml_open_file('xml-search.xml');
$xsl = domxml_xslt_stylesheet_file('style.xsl');
$html = $xsl->process($xml);
echo $html->dump_mem();
?> |
Merci de votre aide.