<X: แยก> แท็ก
<X: แยก> แท็กที่ใช้ในการแก้ไขคุณสมบัติของแท็ก body หรือข้อมูล XML
วากยสัมพันธ์
<x:parse var="<string>" varDom="<string>" scope="<string>" scopeDom="<string>" doc="<string>" systemId="<string>" filter="<string>"/>
คุณสมบัติ
<X: แยก> tag มีคุณลักษณะดังต่อไปนี้:
คุณสมบัติ | ลักษณะ | หากมีความจำเป็น | ผิดนัด |
---|---|---|---|
var | มันมีตัวแปรข้อมูลแจง XML | ไม่ | ไม่ |
XML | ต้องการที่จะแยกข้อความของเนื้อหาเอกสาร (สตริงหรือ Reader) | ไม่ | ร่างกาย |
systemid | ระบบระบุ URI จะใช้ในการแยกวิเคราะห์เอกสาร | ไม่ | ไม่ |
กรอง | ฟิลเตอร์ที่ใช้ในเอกสารแหล่งที่มา | ไม่ | ไม่ |
คุณหมอ | ต้องการที่จะแยกเอกสาร XML | ไม่ | หน้า |
ขอบเขต | แอตทริบิวต์ var ขอบเขต | ไม่ | หน้า |
varDom | มันมีตัวแปรข้อมูลแจง XML | ไม่ | หน้า |
scopeDom | คุณสมบัติ varDom ขอบเขต | ไม่ | หน้า |
ตัวอย่างสาธิต
เขาเอากรณีที่จะบอกเราวิธีการแยกเอกสาร XML:
รหัสแฟ้ม Books.xml เป็นดังนี้:
<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>
รหัสไฟล์ main.jsp เป็นดังนี้:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ 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:parse 标签</title> </head> <body> <h3>Books Info:</h3> <c:import var="bookInfo" url="http://localhost:8080/books.xml"/> <x:parse xml="${bookInfo}" 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