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 Link to comment https://forums.phpfreaks.com/topic/226953-delete-xml-data/ 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 Link to comment https://forums.phpfreaks.com/topic/226953-delete-xml-data/#findComment-1170969 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 Link to comment https://forums.phpfreaks.com/topic/226953-delete-xml-data/#findComment-1171040 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.