By GokiSoft.com|
20:59 08/06/2022|
Học PHP
[XML] Tìm hiểu XSLT - Ứng dụng trong mô hình phát triển MVC
#student.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="student.xsl"?>
<studentList>
<student>
<fullname>TRAN VAN A</fullname>
<age>12</age>
<address>Ha Noi</address>
<email>a@gmail.com</email>
<gender>Nam</gender>
</student>
<student>
<fullname>TRAN VAN B</fullname>
<age>12</age>
<address>Ha Noi</address>
<email>a@gmail.com</email>
<gender>Nam</gender>
</student>
<student>
<fullname>TRAN VAN C</fullname>
<age>12</age>
<address>Ha Noi</address>
<email>a@gmail.com</email>
<gender>Nam</gender>
</student>
</studentList>
#student.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>DANH SACH SINH VIEN</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">Ho Ten</th>
<th style="text-align:left">Tuoi</th>
<th style="text-align:left">Dia Chi</th>
<th style="text-align:left">Email</th>
<th style="text-align:left">Gioi Tinh</th>
</tr>
<xsl:for-each select="studentList/student">
<tr>
<td><xsl:value-of select="fullname"/></td>
<td><xsl:value-of select="age"/></td>
<td><xsl:value-of select="address"/></td>
<td><xsl:value-of select="email"/></td>
<td><xsl:value-of select="gender"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
#vidu.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>XSL Page</title>
</head>
<body>
</body>
</html>
Source Code: https://drive.google.com/file/d/1y82dxF_lyKjH1BuxJZ7J3T99DUCoCQVZ/view?usp=sharingTags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)