PHP XML Remove Parent

swaverresorce

New Member
XML:\[code\]<?xml version="1.0" encoding="ISO-8859-1"?><root> <pages> <page><title>Home</title><content>Lorem Ipsum</content></page> <page><title>Pictures</title><content>Lorem Ipsum</content></page> <page><title>Information</title><content>Lorem Ipsum</content></page> </pages> <css> <css-tag><title>background-color</title><value>#FFF</value></css-tag> </css> <layout>1</layout></root>\[/code\]PHP:\[code\]$title = $_GET['0'];$xml = new DOMDocument('1.0', 'ISO-8859-1');$xml->formatOutput = true;$xml->preserveWhiteSpace = true;$xml->load($location);$pages = $xml->getElementsByTagName("page");foreach($pages as $page){ $pagetitle = $page->getElementsByTagName("title"); $pagetitlevalue = http://stackoverflow.com/questions/10341498/$pagetitle->item(0)->nodeValue; if($title == $pagetitlevalue){ $pagetitle->item(0)->parentNode->removeChild($pagetitle->item(0)); }}$xml->save($location);\[/code\]This code gets rid of just the \[code\]<Title>\[/code\] node, how can it be changed to get rid of the parent \[code\]<Page>\[/code\] node? :)I can't figure out how to do this, I just manage to get rid of the title node and get loads of error codes ;)
 
Back
Top