Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. </head>
  7.  
  8. <body>
  9. <table border="1" align="center">
  10. <?php
  11. if (isset ($_GET["id"]))
  12. {
  13. $tai_lieu = new DOMDocument();
  14. $tai_lieu->load("danh_sach_hoc_vien.xml");
  15. $thedocument = $tai_lieu->documentElement;
  16. $list = $thedocument -> GetElementsByTagName ('hoc_vien');
  17. $nodeToRemove = null;
  18. foreach ( $list as $domElement)
  19. {
  20. $attrValue = $domElement->getAttribute ('ho_ten');
  21. if ($attrValue ==$_GET["id"] )
  22. {
  23. $nodeToRemove = $domElement;
  24. }
  25. }
  26. if ($nodeToRemove != nul )
  27. $thedocument->removeChild($nodeToRemove);
  28. $tai_lieu->save('danh_sach_hoc_vien.xml');
  29.  
  30. }
  31. ?>
  32. <?php
  33. //tạo đối tượng
  34. $tai_lieu = new DOMDocument();
  35. //mở tài liệu XML
  36. $tai_lieu->load("danh_sach_hoc_vien.xml");
  37. //truy xuất node gốc
  38. $node_goc = $tai_lieu->documentElement;
  39. $mang_node_con = $node_goc->childNodes;
  40. foreach($mang_node_con as $node)
  41. {
  42. if($node->nodeType==XML_ELEMENT_NODE)
  43. {
  44. ?>
  45. <tr>
  46. <td><?php echo $node->getAttribute('ho_ten'); ?>&nbsp;</td>
  47. <td><?php echo $node->getAttribute('ngay_sinh'); ?>&nbsp;</td>
  48. <td><?php echo $node->getAttribute('dia_chi'); ?>&nbsp;</td>
  49. <td><?php echo $node->getAttribute('dien_thoai'); ?>&nbsp;</td>
  50. <td><a href="docfile.php?id=<?php echo $node->getAttribute('ho_ten'); ?>" >Xóa</a></td>
  51. </tr>
  52. <?php
  53. }
  54. }
  55. ?>
  56. </table>
  57. </body>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement