feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Right ok...here we go:
I'm building a small scale CMS for a presentation system, which uses a programmed .swf to format an XML document into slides. To update this XML document, I'm building a series of PHP pages (4 in total); a parsing page, editing page, adding new slide page (you'll see what I mean from the XML schema) and a deletion page. The editing and deleting pages work by taking url variables from the parsing page, such as;
[syntax="html"]<a href="edit.php?edit=1">go to editing page</a>
<a href="delete.php?delete=1">go to delete page</a>
etc. etc.
the XML document looks like...
Code: Select all
<?xml version="1.0" encoding="iso-8859-1"?>
<presentation>
<slide id="0">
<element type="title">content</element>
<element type="person">content</element>
<element type="company">content</element>
<element type="presenter">content</element>
<element type="image">content</element>
</slide>
<slide id="1">
<element...
all the sections work fine, except the deleting. this is because the rest of the site is programmed in SimpleXML, which does not have any built in methods for removing or deleting nodes, attributes or children. this is why I have had to use DOM XML for this section.
the code I'm using for this is[/syntax]
Code: Select all
$doc = new DOMDocument;
$doc->load('caseStudy.xml');
$presentation = $doc->documentElement;
// I'm pretty sure that the line underneath is wrong
$slide = $presentation->item('slide[$num]');
$oldslide = $presentation->removeChild($slide);
echo $doc->saveXML();
but this doesn't work, since its giving me errors.
the url for this page would look like
delete.php?delete=3 with the number (delete=3) meaning the number child of presentation that should be deleted.
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]