spamgoat Posted November 25, 2007 Share Posted November 25, 2007 Hey all, I have a a xml with a very basic structure: <root> <template name="name0">data0</template> <template name="name1">data1</template> <template name="name2">data2</template> <template name="name3">data3</template> <template name="name4">data4</template> <template name="name5">data5</template> <template name="name6">data6</template> </root> I'm trying to remove the 4th node in the file (named name3). The code i'm using for this is: <? $i = 3; //Hoping to delete the 4th node. $doc = new DOMDocument(); $doc->load('file:///var/templates.xml'); $items = $doc->getElementsByTagName('template'); $items2 = $items->item($i); $itemg = $items2->nodeValue; echo $itemg; //It does return the value of the item i'm trying to delete. $itemg = $items->removeChild($items2); //Return: "Fatal error: Call to undefined method DOMNodeList::removeChild()" ?> As said above, the script return Fatal error: Call to undefined method DOMNodeList::removeChild(). I've no idea why it isn't working, and definitely not an idea what the correct code would be. Any help would be highly appreciated, spamgoat Quote Link to comment Share on other sites More sharing options...
spamgoat Posted November 25, 2007 Author Share Posted November 25, 2007 It seems to stop erroring when I change the last line from $itemg = $items->removeChild($items2); to $itemg = $items->item(0)->removeChild($items2); But it doesn't actually remove anything. :'( 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.