Currently I am using unset() for removing a parent node in simpleXML, and writing it back to the XML file
I tried this code and it was working a while ago, after cleaning my code I can't find why it doesn't work all of the sudden,
The debugging approaches I took: the file can be accessed, I can enter the loop and if statement, the file gets saved (notepad++ asks me to reload), but the <systemInfo></systemInfo>
does not get deleted
Here is my sample Code:
$userorig = $_POST['user'];
$userinfos = simplexml_load_file('userInfo.xml'); // Opens the user XML file
foreach ($userinfos->userinfo->account as $account)
{
// Checks if the user in this iteration of the loop is the same as $userorig (the user i want to find)
if($account->user == $userorig)
{
echo "hello";
$rootSystem = $account->systemInfo;
unset($rootSystem);
}
}
$userinfos->saveXML('userInfo.xml');
My XML File:
<userinfos>
<userinfo>
<account>
<user>TIGERBOY-PC</user>
<toDump>2014-03-15 03:20:44</toDump>
<toDumpDone>0</toDumpDone>
<initialCheck>0</initialCheck>
<lastChecked>2014-03-16 07:12:17</lastChecked>
<alert>1</alert>
<systemInfo>
... (many nodes and sub nodes here) ...
</systemInfo>
</account>
</userinfo>
</userinfos>