Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- </head>
- <body>
- <table border="1" align="center">
- <?php
- if (isset ($_GET["id"]))
- {
- $tai_lieu = new DOMDocument();
- $tai_lieu->load("danh_sach_hoc_vien.xml");
- $thedocument = $tai_lieu->documentElement;
- $list = $thedocument -> GetElementsByTagName ('hoc_vien');
- $nodeToRemove = null;
- foreach ( $list as $domElement)
- {
- $attrValue = $domElement->getAttribute ('ho_ten');
- if ($attrValue ==$_GET["id"] )
- {
- $nodeToRemove = $domElement;
- }
- }
- if ($nodeToRemove != nul )
- $thedocument->removeChild($nodeToRemove);
- $tai_lieu->save('danh_sach_hoc_vien.xml');
- }
- ?>
- <?php
- //tạo đối tượng
- $tai_lieu = new DOMDocument();
- //mở tài liệu XML
- $tai_lieu->load("danh_sach_hoc_vien.xml");
- //truy xuất node gốc
- $node_goc = $tai_lieu->documentElement;
- $mang_node_con = $node_goc->childNodes;
- foreach($mang_node_con as $node)
- {
- if($node->nodeType==XML_ELEMENT_NODE)
- {
- ?>
- <tr>
- <td><?php echo $node->getAttribute('ho_ten'); ?> </td>
- <td><?php echo $node->getAttribute('ngay_sinh'); ?> </td>
- <td><?php echo $node->getAttribute('dia_chi'); ?> </td>
- <td><?php echo $node->getAttribute('dien_thoai'); ?> </td>
- <td><a href="docfile.php?id=<?php echo $node->getAttribute('ho_ten'); ?>" >Xóa</a></td>
- </tr>
- <?php
- }
- }
- ?>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement