calabiyau Posted December 12, 2008 Share Posted December 12, 2008 I'm trying to delete a node from an xml file. The xml file is structured as follows <pages> <page> <script_files> <script> <script_file></scriptfile> <script_name></script_name> </script> </script_files> </page> </pages> and the code i've been trying is <?php $new_page = $_POST['page']; $script_file = $_POST['script_file']; $xml = new DomDocument('1.0'); $xml->load('../database/content_db.xml'); $sub_doc = $xml->getElementsByTagName('page')->item($new_page); $scripts = $sub_doc->getElementsByTagName('script_files')->item(0); $spec_script = $scripts->getElementsByTagName('script')->item($script_file); $olduser = $scripts->removeChild($spec_script); $xml->save("../database/content_db.xml"); ?> Thing is I had this sort of working with similar code but have gotten lost along the way. Anyone familiar with this sort of work that could send me in the right direction? Thanks Link to comment https://forums.phpfreaks.com/topic/136754-php-xml-dom/ Share on other sites More sharing options...
calabiyau Posted December 13, 2008 Author Share Posted December 13, 2008 Anybody? Link to comment https://forums.phpfreaks.com/topic/136754-php-xml-dom/#findComment-714476 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.