Okay... I want to remove a child, where a certain value matches a given value - here is my code:

function removeUser($login)
{
$xp = new DomXPath($this);
$query = $xp->query("/users/user[login='$login']");

foreach($query as $node)
{
/ magic (isn't) happening here /
}

}

here is a snip of the XML

<users>
<user>
<login>gwb</login>
<name>George Bush</name>
</user>
<user>
<login>wjc</login>
<name>William Clinton</name>
</user>
</users>

Unfortunately I get the following error:

Undefined property: DOMElement::$remove_child in <blah>

--

I'm fairly new to the XML DOM, but apparently I don't really know the difference between an element and a node... what I want to do is remove a <user> with a login of x... any help would be very appreciated.

    Write a Reply...