simpleXML - can't add children - why? - stuck
| From: | MEM | Date: | Wed, 04 Aug 2010 17:10:49 +0000 |
| Subject: | simpleXML - can't add children - why? - stuck | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-307312@lists.php.net to get a copy of this message | ||
Hello all,
I'm struggling here, but no joy so far.
Having this XML file that I'm loading using simplexml_load_file():
http://pastebin.com/JiW3LxWM
I need to add some <domain:create> children nodes after line 8.
What do I need to add?
This:
http://pastebin.com/mT27g3ZN
In order to do so, I have used the following php snipped:
http://pastebin.com/a1gG8tXx
I'm getting this warning and, after it, a fatal error:
Warning: SimpleXMLElement::addChild() [simplexmlelement.addchild]:
Cannot add child. Parent is not a permanent member of the XML tree.
(line number 1 of last paste bin)
Fatal error: Call to a member function addChild() on a non-object
(line number 2 of last paste bin)
Note that:
The constant used is correct. The php version is higher then 5.1.
On the same command, later on this code, I was able to create child
nodes with no issues.
I'm far (veery far) from being a guru, so please, what can I do to
debug this, and find out what's going on?
Thanks a lot,
Márcio