Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>first you have to add this</p> <pre><code> &lt;xsl:output method="html" encoding="UTF-8" indent="no"/&gt; </code></pre> <p>It would tell your XSLT parser that you want to output HTML. </p> <p>to output some content from the XML to HTML you have to use value-of</p> <pre><code>&lt;xsl:value-of select="/xpath/of/xml"/&gt; </code></pre> <p>also depending of the complexity of your output you night need to use <code>&lt;xsl:template name="name"&gt;</code>, it would permit you to make reusable template in the XSLT file. </p> <p>so in your example</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="html" encoding="UTF-8" indent="no"/&gt; &lt;xsl:template match="/"&gt; &lt;xsl:variable name="filename" select="/data/tour/entry/photo/filename"/&gt; &lt;img src="{$filename}"/&gt; &lt;h2&gt;&lt;xsl:value-of select="/data/tour/entry/title"/&gt;&lt;/h2&gt; &lt;xsl:value-of select="/data/tour/entry/description"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>Hope this helps. </p> <p>PHP snippet</p> <pre><code>&lt;?php $xml = new DOMDocument; $xmlC = file_get_contents('data.xml'); $xml-&gt;loadXml( $xmlC); $xsl = new DOMDocument(); $xsl-&gt;load('template.xlst'); // Configuration du transformateur $proc = new XSLTProcessor(); $proc-&gt;importStyleSheet($xsl); // attachement des règles xsl $proc-&gt;registerPHPFunctions(); header('Content-Type: text/xml'); echo $proc-&gt;transformToXML($xml); </code></pre> <p>PS: updated with your XML. I would try in PHP to see if it run ok PS2: updated with running PHP sample and update template</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload