Hello,
I have a problem concerning removeChild. This is the XML structure I use with php:
<xml_thing
<language1
<site>bla1</site
<site>bla2</site
<site>bla3</site
</language1
<language2
</language2
</xml_thing
now, if I want to delete the whole language1 I use the following code:
$toDelete=$xml_ dom->getElementsByT agName('languag e1')->item(0);
$okay = $xml_dom->removeChild($t oDelete);
but if I try to delete a site like that:
$toDelete=$xml_ dom->getElementsByT agName('site')->item(0);
$okay = $xml_dom->removeChild($t oDelete);
i get a Fatal error: Uncaught exception 'DOMException' with message 'Not Found Error'
with google i found a hint how to solve the problem, it said that the removeChild method refers to the current selected node and that I have to use the method having selected the concerning Node. But how can I do this? Probably amateurish I tried to do it like this way:
$toDelete=$xml_ dom->getElementsByT agName('languag e1')->item(0);
$toDelete=$toDe lete->getElementsByT agName('site')->item(0);
normally I use SimpleXML to handle XML-files, but in SimpleXML there is no way to delete a child so I had to use DOM, which I think is very complicated - however I would be very thankful if someone could explain the above mentioned problem to me. thank you!
I have a problem concerning removeChild. This is the XML structure I use with php:
<xml_thing
<language1
<site>bla1</site
<site>bla2</site
<site>bla3</site
</language1
<language2
</language2
</xml_thing
now, if I want to delete the whole language1 I use the following code:
$toDelete=$xml_ dom->getElementsByT agName('languag e1')->item(0);
$okay = $xml_dom->removeChild($t oDelete);
but if I try to delete a site like that:
$toDelete=$xml_ dom->getElementsByT agName('site')->item(0);
$okay = $xml_dom->removeChild($t oDelete);
i get a Fatal error: Uncaught exception 'DOMException' with message 'Not Found Error'
with google i found a hint how to solve the problem, it said that the removeChild method refers to the current selected node and that I have to use the method having selected the concerning Node. But how can I do this? Probably amateurish I tried to do it like this way:
$toDelete=$xml_ dom->getElementsByT agName('languag e1')->item(0);
$toDelete=$toDe lete->getElementsByT agName('site')->item(0);
normally I use SimpleXML to handle XML-files, but in SimpleXML there is no way to delete a child so I had to use DOM, which I think is very complicated - however I would be very thankful if someone could explain the above mentioned problem to me. thank you!
Comment