_items[] = $item; } public function build() { $this->_xw = new XMLWriter(); $this->_xw->openMemory(); $this->_xw->setIndentString( ' ' ); $this->_xw->setIndent( true ); $this->_xw->startDocument( '1.0','UTF-8' ); $this->_xw->startElement( 'rss' ); $this->_xw->writeAttribute( 'xmlns:itunes', 'http://www.itunes.com/DTDs/Podcast-1.0.dtd' ); $this->_xw->writeAttribute( 'version', '2.0' ); $this->_xw->startElement( 'channel' ); $this->_xw->writeElement( 'title', 'radio records' ); $this->_xw->writeElement( 'description', 'recent copies from the web' ); $this->_xw->writeElement( 'link', 'http://gerd.exit0.net/gadgets/dlf' ); $this->_xw->writeElement( 'lastBuildDate', gmdate( self::DATEFORMAT ) ); $this->_xw->writeElement( 'generator', 'me' ); $this->_xw->startElement( 'image' ); $this->_xw->writeElement( 'url', 'http://exit0.net/img/org.png' ); $this->_xw->writeElement( 'title', 'radio records logo' ); $this->_xw->writeElement( 'description', 'recent copies from the web' ); $this->_xw->writeElement( 'link', 'http://gerd.exit0.net/gadgets/dlf' ); $this->_xw->endElement(); $this->_xw->startElement( 'itunes:owner' ); $this->_xw->writeElement( 'itunes:name', 'me' ); $this->_xw->writeElement( 'itunes:email', 'foo@bar.com' ); $this->_xw->endElement(); $this->_xw->writeElement( 'category', 'radio records' ); $this->_xw->writeElement( 'itunes:subtitle', 'something' ); $this->_xw->writeElement( 'itunes:author', 'me' ); $this->_xw->writeElement( 'itunes:explicit', 'no' ); $this->_xw->writeElement( 'language', 'de' ); $this->_xw->writeElement( 'ttl', 300 ); $this->_xw->startElement( 'item' ); foreach( $this->_items as $i ) { $this->_xw->writeElement( 'title', $i['title'] ); $this->_xw->writeElement( 'description', $i['desc'] ); $this->_xw->writeElement( 'link', $i['link'] ); $this->_xw->writeElement( 'author', $i['author'] ); $this->_xw->writeElement( 'pupDate', $i['date'] ); $this->_xw->writeElement( 'guid', $i['ur'] ); $this->_xw->startElement( 'enclosure' ); $this->_xw->writeAttribute( 'url', $i['url'] ); $this->_xw->writeAttribute( 'length', $i['lenght'] ); $this->_xw->writeAttribute( 'type', $i['type'] ); $this->_xw->endElement(); $this->_xw->writeElement( 'itunes:duration', 'me' ); $this->_xw->writeElement( 'itunes:author', 'me' ); } $this->_xw->endElement(); $this->_xw->endElement(); $this->_xw->endElement(); $xml = $this->_xw->outputMemory(true); echo $xml; } } $p = new RSSThingy(); $item = array( 'title' => 'foo', 'desc' => 'bar', 'author' => 'Deutschlandfunk', ); $p->addItem(); $p->build(); ?>