คุณสมบัติ
| แอตทริบิวต์ | คำอธิบาย | จำเป็น | ค่าเริ่มต้น |
|---|---|---|---|
| เลือก | นิพจน์ XPath เพื่อประเมินเป็นสตริง มักใช้ตัวแปร XPath | ใช่ | ไม่มี |
| escapeXml | จริงถ้าแท็กควรหลีกเลี่ยงอักขระ XML พิเศษ | ไม่ | จริง |
ตัวอย่าง
ให้เรายกตัวอย่างที่จะครอบคลุมแท็ก (a)
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix = "x" uri = "http://java.sun.com/jsp/jstl/xml" %>
<html>
<head>
<title>JSTL x:out Tags</title>
</head>
<body>
<h3>Books Info:</h3>
<c:set var = "xmltext">
<books>
<book>
<name>Padam History</name>
<author>ZARA</author>
<price>100</price>
</book>
<book>
<name>Great Mistry</name>
<author>NUHA</author>
<price>2000</price>
</book>
</books>
</c:set>
<x:parse xml = "${xmltext}" var = "output"/>
<b>The title of the first book is</b>:
<x:out select = "$output/books/book[1]/name" />
<br>
<b>The price of the second book</b>:
<x:out select = "$output/books/book[2]/price" />
</body>
</html> รหัสข้างต้นจะให้ผลลัพธ์ดังต่อไปนี้ -
Books Info: The title of the first book is: Padam History The price of the second book: 2000