Bonjour j'ai un problème avec XML et PHP j'ai toujours cette erreur là:
"Warning: Sablotron error on line 1: XML parser error 4: not well-formed (invalid token) in d:\work\dev\php\php-object\tutoriaux\parsexml.php on line 6"
Et je ne trouve pas l'erreur
Voilà mon fichier php(extrait de la doc PHP) :
Code :
- <?php
- // Allocate a new XSLT processor
- $xh = xslt_create();
- // Process the document, returning the result into the $result variable
- $result = xslt_process($xh, "xml-file.xml", "xsl-file.xsl" );
- if ($result)
- {
- print "<pre>\n";
- print $result;
- print "</pre>\n";
- }
- xslt_free($xh);
- ?>
|
Voilà mon fichier XML avec la DTD intégrée:
Code :
- <?xml version='1.0' encoding='UTF-8'?>
- <!DOCTYPE article[
- <!ELEMENT title (#PCDATA)>
- <!ELEMENT section (title?, para+)>
- <!ELEMENT title (#PCDATA)>
- <!ELEMENT para (#PCDATA)>
- ]>
- <article>
- <title>titre</title>
- <section>
- <title>titre de la section</title>
- <para>blablablablablablablablablabal</para>
- </section>
- </article>
|
Et mon fichier XSL:
Code :
- <xml version='1.0'?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
-
- <xsl:output method="html"/>
- <xsl:template match="/">
- <html>
- <head><title><xsl:value-of select="title"/></title></head>
- <body>
- <xsl:apply-templates/>
- </body>
- </html>
- </xsl:template>
-
- <xsl:template match="article/title">
- <h1><xsl:value-of select="."/></h1>
- </xsl:template>
-
- <xsl:template match="section">
- <xsl:apply-templates/>
- </xsl:template>
-
- <!-- Formatting for JUST section titles -->
- <xsl:template match="section/title">
- <h2><xsl:value-of select="."/></h2>
- </xsl:template>
-
- <xsl:template match="para">
- <P><xsl:apply-templates/></P>
- </xsl:template>
- </xsl:stylesheet>
|
Je précise que le support d'XSLT est disponible sur mon serveur.
Voilà si jamais quelqu'un a une idée, je suis preneur
Merci d'avance.
