I am having a bit of difficulty. I have an XML database, in which information about users is stored on a website in such a format...

: ***** represents data


Code:

<user>
  <password>*****</password>
  <email>***** </email>
  <tutorial> ***** </tutorial>
  <team> ***** <team>
  <canreview> ***** </canreview>
  <joblist>
    <job>
      <date> ***** </date>
      <type> ***** </type>
    </job>
    <job>
      <date> ***** </date>
      <type> ***** </type>
    </job>
  </joblist>
</users> 


What I want to do is delete an entire <job> node out of this file. The problem is... the actual <job> node being deleted is variable. It could be the first, the second, or any one after that. Here is what i have so far.

The script that is going to do the deletion is within a file called actionscript.php. I send data to the file by calling this URL.


Code:
<a href="actionscript.php?action=deletenode&user=' . $_SESSION['username']  . '&node=' . $node . '">';


And in the PHP script


Code:

$action = $_GET['action'];
$user = $_GET['user'];
$node = $_GET['node'];
... some php code
if($action == 'deleteuser') {
    $xml = //file is at 'user/' . $_SESSION['username'] . '.xml'
  // and here begins my problems
 //     1. I want to use Simple XML, but Simple XML can't delete nodes.
// That leaves me with DOM Document
// how do i use dom doc? I've really always used Simple XML and, till now, its served my needs.
// the tutorials i've found online don't help me with this particular usage..
}
http://www.kavoir.com/2008/12/how-to-delete-remove-nodes-in-simplexml.html

Be sure to read the comments as well because they present an alternative approach to the above solution.
Success! Thanks...

it appears that 'unset' doesnt work if the argument provided is a parent function. You have to be doing it on a child function.
Another Question:

Is there a way to create a PayPal "Pay Now" button, but supply a price, such that their database gets overridden?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement