IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Bibliothèques et frameworks PHP Discussion :

[XSLT][DOM] Php - Xml - Xsl


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    Membre confirmé
    Avatar de topolino
    Profil pro
    Inscrit en
    Juillet 2003
    Messages
    1 901
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2003
    Messages : 1 901
    Points : 637
    Points
    637
    Par défaut [XSLT][DOM] Php - Xml - Xsl
    Bonjour,

    je n'arrive pas a recuperer les infos de mon fichier XML.

    XML :
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    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 xml : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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.
    MCTS Microsoft.
    La conception : Prendre le temps pour gagner du temps.

  2. #2
    Expert confirmé
    Avatar de siddh
    Inscrit en
    Novembre 2005
    Messages
    3 868
    Détails du profil
    Informations personnelles :
    Âge : 47

    Informations forums :
    Inscription : Novembre 2005
    Messages : 3 868
    Points : 5 011
    Points
    5 011
    Par défaut
    essayes :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    $path = dirname(__FILE__)."/";
    $xml = domxml_open_file($path.'xml-search.xml');
    $xsl = domxml_xslt_stylesheet_file($path.'style.xsl');
    dans certaines versions de php il faut un chemin absolu sinon ca marche pas
    Alunissage : Procédé technique consistant à déposer des imbéciles sur un rêve enfantin.

    Cours | FAQ | Sources Javascript
    Cours | FAQ | Sources PHP
    Mes Articles

  3. #3
    Membre confirmé
    Avatar de topolino
    Profil pro
    Inscrit en
    Juillet 2003
    Messages
    1 901
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2003
    Messages : 1 901
    Points : 637
    Points
    637
    Par défaut
    toujours pas, je ne comprends pas pourquoi je n'arrive a rien recuperer !!!! page blanche
    MCTS Microsoft.
    La conception : Prendre le temps pour gagner du temps.

  4. #4
    Expert confirmé
    Avatar de siddh
    Inscrit en
    Novembre 2005
    Messages
    3 868
    Détails du profil
    Informations personnelles :
    Âge : 47

    Informations forums :
    Inscription : Novembre 2005
    Messages : 3 868
    Points : 5 011
    Points
    5 011
    Par défaut
    mwé ben deja met un select= pour ton apply-templates
    et met ca aussi :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <xsl:for-each select="//RESULTSET">
    Alunissage : Procédé technique consistant à déposer des imbéciles sur un rêve enfantin.

    Cours | FAQ | Sources Javascript
    Cours | FAQ | Sources PHP
    Mes Articles

Discussions similaires

  1. La solution PHP+XML+XSL=Template est-elle viable ?
    Par TempusFugit dans le forum Langage
    Réponses: 1
    Dernier message: 03/10/2007, 13h52
  2. [DOM] PHP5 : xml+xsl ou dom+xml
    Par thibaut06 dans le forum Bibliothèques et frameworks
    Réponses: 4
    Dernier message: 25/08/2007, 19h12
  3. Réponses: 4
    Dernier message: 16/07/2006, 14h00
  4. PHP/XML/XSL
    Par sami69 dans le forum XSL/XSLT/XPATH
    Réponses: 4
    Dernier message: 10/04/2006, 14h30

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo