breex Posted January 29, 2007 Share Posted January 29, 2007 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 ?[u]code causing error: [/u]$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}[u]xml structure:[/u]<books> <book> <title></title> <subtitle></subtitle> <publisher></publisher> <year></year> <cover></cover> <cover_thumb></cover_thumb> </book></books>[u]complete error:[/u]Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-addChild]: Node no longer exists in C:\Program Files\XAMPP\xampp\htdocs\php\Book.class.php on line 171Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-addChild]: Node no longer exists in C:\Program Files\XAMPP\xampp\htdocs\php\Book.class.php on line 172Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-addChild]: Node no longer exists in C:\Program Files\XAMPP\xampp\htdocs\php\Book.class.php on line 173Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-addChild]: Node no longer exists in C:\Program Files\XAMPP\xampp\htdocs\php\Book.class.php on line 174Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-addChild]: Node no longer exists in C:\Program Files\XAMPP\xampp\htdocs\php\Book.class.php on line 175Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-addChild]: Node no longer exists in C:\Program Files\XAMPP\xampp\htdocs\php\Book.class.php on line 176 Link to comment https://forums.phpfreaks.com/topic/36198-simplexml-error-node-no-longer-exists-using-addchild/ Share on other sites More sharing options...
breex Posted January 29, 2007 Author Share Posted January 29, 2007 *bump* Link to comment https://forums.phpfreaks.com/topic/36198-simplexml-error-node-no-longer-exists-using-addchild/#findComment-172032 Share on other sites More sharing options...
breex Posted January 29, 2007 Author Share Posted January 29, 2007 I found the answer and post it so nobody needs to break his head over this like i did >:(when using simplexml_load_file() it automatically select the root-node.So when I was doing [code]$book = $xml->books->addChild('book');[/code]I was trying to select the root (being books) while already being on it. Thats why it gave me a "Node no longer exists" error (should have gave me something like "Node yur trying to select doesnt exist") Link to comment https://forums.phpfreaks.com/topic/36198-simplexml-error-node-no-longer-exists-using-addchild/#findComment-172137 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.