I am using a simple simplexml php file to add to my XML file. For some reason it is not placing the record into the XML file and my logs are showing
PHP Fatal error: Call to a member function addChild()
Wondering can someone help me out? Might be something really simple. I am attaching the PHP code and the XML file.
PHP:
<?php
$file = 'news.xml';
$xml = simplexml_load_file($file);
$story = $xml->news->story;
$story->addChild('storyid', '33');
$story->addChild('story_pic', 'images/test.jpg');
$story->addChild('story_title', 'Your Title');
$story->addChild('story', 'This is a test story');
$story->addChild('story_date', '01/01/2001');
$xml->asXML($file);
?>
XML
<?xml version = "1.0" encoding="Windows-1252" standalone="yes"?>
<news>
<story>
<storyid>1</storyid>
<story_pic>http://portfoliotheme.org/enigmatic/wp-content/uploads/sites/9/2012/07/placeholder1.jpg</story_pic>
<story_title>My Test News Story</story_title>
<story>fdsfsfsdfdsfdsfsfsdfdsfsfdffsfdssfd</story>
<story_date>22/01/2016</story_date>
</story>
<story>
<storyid>2</storyid>
<story_pic>http://portfoliotheme.org/enigmatic/wp-content/uploads/sites/9/2012/07/placeholder1.jpg</story_pic>
<story_title>My Test News Story2</story_title>
<story>fdsfsfsdfdsfdsfsfsdfdsfsfdffsfdssfd</story>
<story_date>22/01/2016</story_date>
</story>
</news>
$story?