..oO(Jeff)
>Michael Fesser wrote:
>I build my feeds with the DOM extension.
I've just looked through this. Are you using that to generate the RSS or
to read the html. Care to share any details? I can't see how this would
write an RSS feed, but I may have missed something.
I use it to create the RSS. My feed is just another script, which
collects the data for the feed and then uses DOM to create the XML for
the feed.
Somewhere in my RSS component I have the following method (slightly
modified here, because the actual data may come from different sources
like a database for example):
private function createXml() {
$doc = new DOMDocument('1.0', 'UTF-8');
$doc->formatOutput = TRUE;
$rss = $doc->createElement('rss');
$rss->appendChild(new DOMAttr('version', '2.0'));
$doc->appendChild($rss);
$channel = $doc->createElement('channel');
$rss->appendChild($channel);
// create channel info like title, description and URL
foreach (getChannelInfoFromSomewhere() as $field =$value) {
$channel->appendChild(new DOMElement($field,
htmlspecialchars($value))
);
}
// create items and append to channel
foreach (getItemDataFromSomewhere() as $data) {
$item = $doc->createElement('item');
foreach ($data as $field =$value) {
$item->appendChild(new DOMElement($field,
htmlspecialchars($value))
);
}
$channel->appendChild($item);
}
return $doc;
}
This method creates the entire feed and returns it as a DOM document.
The calling method then more or less just has to output the XML to the
browser (besides setting correct HTTP response headers):
$xml = $this->createXml()->saveXML();
...
print $xml;
One result of this all you can see here:
http://ra-pauli.de/beratung/verkehrsrecht/rss
Have a look at the source code - this is what is created by my
createXml() method and the DOM::saveXML() output method.
Micha