Hi,
I have an xml file of this format.
<?xml version="1.0" encoding="ISO-8859-1"?>
<contacts>
<entry uri="sip:vinayg@company.org">
<name>Vinay</name>
<sip> sip:vinayg@company.org </sip>
<Number> 9885821530 </Number>
</entry>
<entry uri="sip:vivek@company.org">
<name>Vivek</name>
<sip> sip:vivek@company.org </sip>
<Number> 9885821530 </Number>
</entry>
</contacts>
Do note that in this XML file, the tag 'entry' is an array. My code is like this. My intention is to device a function that will delete an entry tag along with all its child nodes depending upon the uri passed to it.
function deletePerson($id) {
// SETUP $doc
$doc = new DomDocument;
$doc->validateOnParse = true;
$doc->Load('test.xml');
//REMOVE ID
$user= $doc->getElementByID($id);
$users= $doc->documentElement;
if ($oldPerson = $users->removeChild($user)) {
// worked
} else {
return "Couldn't remove $id listing";
}
$doc->save('test.xml');
}
deletePerson("sip:vinod@company.org");
When this function is executed the entry tag with uri value "sip:vinod@company.org" must be deleted.
Kindly help urgently,
With regards,
tvks