By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,747 Members | 1,671 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,747 IT Pros & Developers. It's quick & easy.

SimpleXML Error: Node no longer exists (using addChild())

P: n/a
Hi,

like the title says simplexml is giving me a "Node no longer exists"
error while using the addChild() function. Note that it's not giving
an error on the first addChild();

Can somebody help ?
code causing error:

$xml = simplexml_load_file("../xml/books.xml");

if($xml) {

$book = $xml->books->addChild('book');
$book->addChild('title',$this->myTitle); //
line 171
$book->addChild('subtitle',$this->mySubTitle);
$book->addChild('publisher',$this->myPublisher);
$book->addChild('year',$this->myYear);
$book->addChild('cover',$this->cover);
$book->addChild('cover_thumb',$this->cover_thumb); // line 176
}

xml structure:

<books>
<book>
<title></title>
<subtitle></subtitle>
<publisher></publisher>
<year></year>
<cover></cover>
<cover_thumb></cover_thumb>
</book>
</books>

complete error:

Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-
addChild]: Node no longer exists in C:\Program Files\XAMPP\xampp\htdocs
\php\Book.class.php on line 171

Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-
addChild]: Node no longer exists in C:\Program Files\XAMPP\xampp\htdocs
\php\Book.class.php on line 172

Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-
addChild]: Node no longer exists in C:\Program Files\XAMPP\xampp\htdocs
\php\Book.class.php on line 173

Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-
addChild]: Node no longer exists in C:\Program Files\XAMPP\xampp\htdocs
\php\Book.class.php on line 174

Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-
addChild]: Node no longer exists in C:\Program Files\XAMPP\xampp\htdocs
\php\Book.class.php on line 175

Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-
addChild]: Node no longer exists in C:\Program Files\XAMPP\xampp\htdocs
\php\Book.class.php on line 176

Jan 29 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.