I am loading up an xml file and using xslt to transform it the way i want to view it. the problem is, some characters are getting converted to things like &lt; which is of course a standard XML for special caracters. This means when i print out the HREF, it doesn't actually create the HREF link...instead i get the whole html code since the character < is converted to &lt; ) This is causing me great pain....anyone know how to get around it? here is my code


PHP:

$xsl_file = "myws.xslt";
$xml_file = "myws.xml";
$xh = xslt_create();
$new_result = xslt_process($xh, $xml_file, $xsl_file);
print $new_result;

xslt_free($xh);

XML :

<link><![CDATA[<A HREF="http://www.myurl.com">CLICK HERE</A>]]></link>

HTML view source :

&lt;A HREF="http://www.myurl.com"&gt;CLICK HERE&lt;/A&gt;

HTML view browser :

<A HREF="http://www.myurl.com">CLICK HERE</A>

any ideas what is going on and how i can fix this?

    Hi Teufboy,
    how are you, you seem to have a problem with your cdata-section-elements. But don't worry, it's possible !!!! Try this !

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl: output cdata-section-elements="FICHIER_RAPPORT"/>
    <xsl:template match="LISTE_RAPPORT/SUJET">
    <HTML>
    <HEAD>
    <TITLE>
    </TITLE>
    </HEAD>
    <BODY BGCOLOR="#EAEAAE">
    <br/>
    <br/>
    <table border='1' cellpadding ='6' CELLSPACING='0' bordercolor='#000000'>
    <tr>
    <td><xsl:value-of select="@NUMERO"/></td>
    <td><xsl:value-of select="TITRE"/></td>
    <td><xsl:value-of select="PROF_RESP"/></td>
    <td><xsl:value-of select="ETUDIANT"/></td>
    <td><xsl:value-of select="FICHIER_RAPPORT"/></td>
    <td><xsl:value-of select="FICHIER_PRESENTATION"/></td>
    <td><xsl:value-of select="DATE_PRESENTATION"/></td>
    </tr>

    			</table>
      </BODY>
    </HTML>
    </xsl:template>

    </xsl:stylesheet>

      Ohhh thank you so much Teufboy,
      your incredibliy clever, how can I thank you for all the time you've spent ?? But the problem isn't solved !!! The document is well formed, but style have the caracters : &gt; &lt;.
      Has someone an idea ????
      Please 😕

        Write a Reply...