I am trying to create a xml file and save it using domXML. However when it creates the xml file it does not create a parent node. This is how the xml file writes now.
<?xml version="1.0"?>
<feed>
<headline></headline>
<author></author>
<link></link>
<image></image>
<description></description>
</feed>
I need the xml file to look like this when it it is created and need to be able to insert more items into <feeds>
<?xml version="1.0"?>
<feeds>
<feed>
<headline></headline>
<author></author>
<link></link>
<image></image>
<description></description>
</feed>
</feeds>
Here is the script I am using. I'd appreciate it if anyone could help point me in the right direction.
$mainheadline = $_POST['headline'];
$mainauthor = $_POST['author'];
$mainlink = $_POST['link'];
$mainimage = $_POST['image'];
$maindescription = $_POST['description'];
$doc = new DOMDocument('1.0');
// we want a nice output
$doc->load("newsfeed/newsfeed.xml");
$root = $doc->createElement('feeds');
$root = $doc->appendChild($root);
$xml = $doc->createElement('feed');
$xml = $root->appendChild($xml);
$headline = $doc->createElement('headline', $mainheadline);
$headline = $xml->appendChild($headline);
$author = $doc->createElement('author', $mainauthor);
$author = $xml->appendChild($author);
$link = $doc->createElement('link', $mainlink);
$link = $xml->appendChild($link);
$image = $doc->createElement('image', $mainimage);
$image = $xml->appendChild($image);
$description = $doc->createElement('description', $maindescription);
$description = $xml->appendChild($description);
$doc->save("newsfeed/newsfeed.xml");