Thanks for the idea, NogDog. I'm trying it but hitting a problem.
Current Code:
<?php
$xml = simplexml_load_file('test.xml');
$cat1 = 'cat one';
$descrip = 'The description.';
$perma = time() . 'mysite-dot-net' . rand(0, 10000);
$TheLink = 'http://www.example.com/';
$ThePubDate = strftime('%a, %d %b %Y %H:%M:%S %z');
$TheTitle = 'The New Title';
$dom_xml = dom_import_simplexml($xml);
$dom = new DOMDocument(1.0); //line 17
$dom_xml = $dom->importNode($dom_xml, true); //line 18
$dom_xml = $dom->appendChild($dom_xml); //line 19
$elements = $dom_xml->get_elements_by_tagname("item"); //line 20
$element = $elements[0];
$NewNode = $element->insert_before($element, $element);
$xml = simplexml_import_dom($dom_xml);
$NewOne = $xml->channel->item[0];
$NewOne->addChild('category', $cat1);
$NewOne->addChild('description', $descrip);
$NewOne->addChild('guid', $perma);
$NewOne->addChild('link', $TheLink);
$NewOne->addChild('pubDate', $ThePubDate);
$NewOne->addChild('title', $TheTitle);
$xml->asXML('test.xml');
?>
My Zend debugger says this:
Fatal error: Call to undefined method DOMElement::get_elements_by_tagname() in testr.php on line 20
Why would it say that's an undefined method?
Also, I'm not sure if lines 17, 18 and 19 are necessary.
I really appreciate your help!