Can you please give me some EASY examples on how to parse and format them the way i want? Please use simple functions because i'm not "comfortable" with classes, yet. Still learning
Thanx in advance for any reply / resource site etc.,
Nick
Moderator: General Moderators
Code: Select all
<?php
// a simple stylesheet to process rdf
$xsl = <<<EOX
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rss="http://my.netscape.com/rdf/simple/0.9/"
>
<xsl:output method="html" />
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="rdf:RDF">
<div class="feed">
<xsl:apply-templates />
</div>
</xsl:template>
<xsl:template match="rss:channel">
<div>
<span class="channel">
<xsl:value-of select="rss:title" />
</span>
<span class="description">
<xsl:value-of select="rss:description" />
</span>
</div>
</xsl:template>
<xsl:template match="rss:item[position() mod 2=0]">
<a>
<xsl:attribute name="class">itemlink_even</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="rss:link" />
</xsl:attribute>
<xsl:value-of select="rss:title" />
</a>
</xsl:template>
<xsl:template match="rss:item[position() mod 2=1]">
<a>
<xsl:attribute name="class">itemlink_odd</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="rss:link" />
</xsl:attribute>
<xsl:value-of select="rss:title" />
</a>
</xsl:template>
<xsl:template match="*">
<fieldset>
<xsl:value-of select="name()" />
<br/>
<xsl:value-of select="namespace-uri()" />
</fieldset>
</xsl:template>
</xsl:stylesheet>
EOX;
$rdf = file_get_contents('http://www.devnetwork.net/service/forum_lastposts.php?limit=10&client=klip');
$arguments = array(
'/_xml' => $rdf,
'/_xsl' => $xsl
);
$xh = xslt_create();
$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
echo $result;
?>