createElement("div"); $div->setAttribute("xmlns", "http://www.w3.org/1999/xhtml"); $div->setAttribute("id", "RSSkentta"); $doc->appendChild($div); // RSS-syötteen osoite on request-muuttujassa $feed = new DOMDocument(); $feed->load($_REQUEST["url"]); // luodaan otsikko/linkki $titlet = $feed->getElementsByTagName("title"); $linkit = $feed->getElementsByTagName("link"); $h2 = $doc->createElement("h2"); $div->appendChild($h2); $a = $doc->createElement("a"); $a->setAttribute("href", $linkit->item(0)->textContent ); $a->appendChild($doc->createTextNode($titlet->item(0)->textContent)); $h2->appendChild($a); // otetaan syötteestä kaikki ITEM elementit $items = $feed->getElementsByTagName("item"); foreach ($items as $item) { // tehdään jokaiselle uutiselle oma divi $uutisdiv = $doc->createElement("div"); $uutisdiv->setAttribute("class", "newsdiv"); // lisätään diviin viestin TITLE (H3) jos ne on olemassa $title = $item->getElementsByTagName("title"); $linkki = $item->getElementsByTagName("link"); if ($title->item(0) != '' && $linkki->item(0) != '') { $h3 = $doc->createElement("h3"); $uutisdiv->appendChild($h3); $a = $doc->createElement("a"); $a->setAttribute("href", $linkki->item(0)->textContent ); $a->appendChild($doc->createTextNode($title->item(0)->textContent)); $h3->appendChild($a); } // lisätään diviin viestin DESCRIPTION (P) $description = $item->getElementsByTagName("description"); if ($description->item(0)!='') { $p = $doc->createElement("p"); $p->appendChild($doc->createTextNode($description->item(0)->textContent)); $uutisdiv->appendChild($p); } // lisätään uutisdiv päädiviin $div->appendChild($uutisdiv); } echo $doc->saveXML(); ?>