socox11 Posted February 7, 2011 Share Posted February 7, 2011 Hi all, I'am new with PHP, and I need help with this one. I have this XML structure: <?xml version="1.0" encoding="UTF-8"?> <popis> <student> <prezime>Brkic</prezime> <ime>Ivica</ime> <index>D-142</index> </student> <student> <prezime>Cizek</prezime> <ime>Pero</ime> <index>D-143</index> </student> </popis> and I have this PHP code to get all elements from XML file to html table: <?php $doc = new DOMDocument(); $doc->load( 'student.xml' ); $popis = $doc->getElementsByTagName( "student" ); echo <<<EOF <table> <tr> <th width=100 >IME</th> <th width=100>PREZIME</th> <th width=100>INDEX</th> </tr> EOF; foreach( $popis as $student ) { $imena = $student->getElementsByTagName( "ime" ); $ime = $imena->item(0)->nodeValue; $prezimena= $student->getElementsByTagName( "prezime" ); $prezime= $prezimena->item(0)->nodeValue; $indexi = $student->getElementsByTagName( "index" ); $index = $indexi->item(0)->nodeValue; echo <<<EOF <tr> <td>{$ime}</td> <td>{$prezime}</td> <td>{$index}</td> </tr> EOF; } echo '</table>'; ?> Now I would like to know how to delete node from XML document? Something like, when I enter number of node I wanna delete in some iput field, or by searching, what ever, just that I can specify which node to delete... My eng is not very good, hope you understand... ty Quote Link to comment Share on other sites More sharing options...
beegro Posted February 7, 2011 Share Posted February 7, 2011 I see you're using the DOM object from PHP. Take a look at this URL for some examples of removing child elements form your XML document: http://us.php.net/manual/en/domnode.removechild.php Quote Link to comment Share on other sites More sharing options...
socox11 Posted February 7, 2011 Author Share Posted February 7, 2011 Thx, I'll try meke it work Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.