Collin Posted February 26, 2006 Share Posted February 26, 2006 Hello all! :)I've run in a bit of trouble and can't figure out what's wrong...I'm using PHP5 I have an xml document and I want to edit it. It's used for making a navigation tree, so it's full of "url" tags... I can read it (the navigation tree shows up you as I want it), I can change values and attributes of tags in the xml document, but I cannot add new nodes to the document... :(It's quite straight forward: create an element, and add it to the end of the children of a node. The problem is that the "create_element()" method doesn't return an object. In fact it doesn't return anything I can detect... :( the error is: [b]domnode::append_child() expects parameter 1 to be object[/b]I've read up on this, and most problems arise from not enabling the XMLDOC extension in the PHP.ini, but since I can do all things "dom", I don't think the extension is the problem... Other than that I haven't found any real solutions... :(Maybe there is something... Can you only add new nodes to a [b]new[/b] document, and not an existing one? Or can't I add anything using xpath?This is the code:[code] global $xPath,$xmlDoc,$root; $xPathResult = xpath_eval($xPath, "//@id"); foreach ($xPathResult->nodeset as $currentNode) { if ($currentNode->value == $_GET['lte']) { $currentNode = $currentNode->parent_node(); $newNode = $xmlDoc->create_element("url"); $currentNode->append_child($newNode); } }[/code] Quote Link to comment Share on other sites More sharing options...
bnmng Posted March 17, 2008 Share Posted March 17, 2008 I think you need appendchild and createelement without the underscores. If you're using PHP5, then look for DOM command, instead of XMLDOM commands. Info here: http://us3.php.net/dom Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.