skrypt:
<?php function dodajitem($id,$title,$link,$updated,$description,$author) { $dom = simplexml_load_file('new.xml'); $item = $dom->xpath("/rss/channel/item[last()]"); foreach ($item as $it){ $lastID=$it->ID; } $id = $this->createElement("id"); $title = $this->createElement("title"); $title->appendChild($this->createTextNode(iconv("ISO-8859-2","UTF-8",$tytul))); $link = $this->createElement("link"); $link->appendChild($this->createTextNode(iconv("ISO-8859-2","UTF-8",$link))); $updated = $this->createElement("updated"); $updated->appendChild($this->createTextNode(iconv("ISO-8859-2","UTF-8",$updated))); $description = $this->createElement("description"); $description->appendChild($this->createTextNode(iconv("ISO-8859-2","UTF-8",$description))); $author = $this->createElement("author"); $author->appendChild($this->createTextNode(iconv("ISO-8859-2","UTF-8",$author))); $item = $this->createElement("item"); $item->appendChild($this->createTextNode("n ")); $item->appendChild($id); $item->appendChild($this->createTextNode("n ")); $item->appendChild($title); $item->appendChild($this->createTextNode("n ")); $item->appendChild($link); $item->appendChild($this->createTextNode("n ")); $item->appendChild($updated); $item->appendChild($this->createTextNode("n ")); $item->appendChild($description); $item->appendChild($this->createTextNode("n ")); $item->appendChild($author); $item->appendChild($this->createTextNode("n ")); $this->documentElement->appendChild($this->createTextNode(" ")); $this->documentElement->appendChild($item); $this->documentElement->appendChild($this->createTextNode("n")); } $item = new DOMDocument('1.0', 'iso-8859-2'); $item->load("new.xml"); $item->dodajitem("0","coś","http://jakis.adres.url", "data", "opis", "emailautora"); $item->saveXML(); $item->save("new.xml"); ?>
plik new.xml:
<?xml version="1.0" encoding="iso-8859-2"?> <rss version="2.0"> <channel> <title></title> <link></link> <description></description> <language></language> <webMaster></webMaster> <image> <title></title> <link></link> <url></url> <height></height> <width></width> </image> <item> <id></id> <title></title> <link></link> <updated></updated> <description></description> <author></author> </item> </channel> </rss>
Jeśli taki temat jest to przepraszam, lecz zależy mi na szybkiej odpowiedzi. Widze, że nikt nie umie mi pomóc, szkoda.