Hello here is an outline of my XML file.
Here is the PHP file that adds to the XML file, if anyone needed to see it.Code:<userlist> <user> <name>Bob</name> <time>11:04:23</time> </user> <user> <name>John</name> <time>11:02:03</time> </user> </userlist>
What I need to do is to loop through the XML file, using the DOMdocument, and remove all 'users' that have a time that is 2 seconds less than the current UTC time. Since each 'user' element has children they will have to be deleted too.Code:<?php $dname = $_POST['dname']; $ptime = $_POST['ptime']; //////////////////////////////////// $doc = new DOMDocument(); $doc->load('userupdate.xml'); $user = $doc->createElement("user"); $doc->getElementsByTagName('userlist')->item(0)->appendChild($user); $name = $doc->createElement("name"); $user->appendChild($name); $time = $doc->createElement("time"); $user->appendChild($time); $textName = $doc->createTextNode($dname); $name->appendChild($textName); $textTime = $doc->createTextNode($ptime); $time->appendChild($textTime); $doc->save("userupdate.xml"); ?>
How do I do this?




Reply With Quote