0
<?xml version="1.0"?>
<rights>
 <visitor>
  <user>updateUsers</user>
  <user>deleteUsers</user>
  <user>createUsers</user>
  <user>readUsers</user>
 </visitor>
</rights>

This is the xml file i am using. I want to delete the nodes depending on their values. Eg if the user want me to remove the entry for updateUsers then i could remove the <user> that has value updateUsers. I want to do it using php. here is my script

$xmlobj=simplexml_load_file($xmlpath);

foreach($xmlobj->{$owner}[0]->children() as $mychild)
{
   $childvalues[]=$mychild;                    
}

foreach($childvalues as $values)
{
  if($userentry==$values)
  {
    //code to remove that node
  }
}

I am struck with it. Help will be very much appreciated

juniorb2s
  • 242
  • 4
  • 11
Let me see
  • 5,063
  • 9
  • 34
  • 47
  • Look at the 1st 2 answers on this question http://stackoverflow.com/questions/262351/remove-a-child-with-a-specific-attribute-in-simplexml-for-php. – Rolando Isidoro Nov 19 '13 at 12:01

1 Answers1

0

Remove the child element from the parent node.

PHP Simple XML remove all Children

Community
  • 1
  • 1
Sridhar
  • 71
  • 1
  • 1
  • 11