Намерих си един бъг в XSLT-файла - при една страница, няма пейджър и дава празен линк.
Поправено:
GeSHi (XML):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output
method="xml"
omit-xml-declaration="no"
doctype-public="//Netscape Communications//DTD RSS 0.91//EN"
doctype-system="http://my.netscape.com/publish/formats/rss-0.91.dtd"
indent="yes"
/>
<xsl:template match="/">
<rss>
<channel>
<title>Linux за българи: Форум</title>
<xsl:apply-templates select="/html/body//table/tr/td/table/tr[position() > 1]/td[position()=3]/a[position()=1]"/>
</channel>
</rss>
</xsl:template>
<xsl:template match="a">
<item>
<title><xsl:value-of select="." /></title>
<link>
<xsl:choose>
<xsl:when test="../span/a[last()-1]/@href">
<xsl:value-of select="../span/a[last()-1]/@href" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="./@href" />
</xsl:otherwise>
</xsl:choose>
</link>
</item>
</xsl:template>
</xsl:stylesheet>
GeSHi (PHP):
<?php
function getContent()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.linux-bg.org/forum/index.php?action=login2');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'user=USERNAME&passwrd=PASSWORD');
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
curl_setopt($ch, CURLOPT_URL, 'http://www.linux-bg.org/forum/index.php?action=unreadreplies');
$content = curl_exec ($ch);
curl_close ($ch);
return $content;
}
$html = getContent();
$dom = new DOMDocument();
@$dom->loadHTML($html);
$xslDoc = new DOMDocument();
$xslDoc->load("rss.xsl");
$proc = new XSLTProcessor();
$proc->importStylesheet($xslDoc);
header("Content-type: application/rss+xml; encoding=utf-8");
echo $proc->transformToXML($dom);