<X: parse> tag
<X: parse> tag is used to resolve property tag body or XML data.
Syntax
<x:parse var="<string>" varDom="<string>" scope="<string>" scopeDom="<string>" doc="<string>" systemId="<string>" filter="<string>"/>
Attributes
<X: parse> tag has the following attributes:
Attributes | description | If necessary | Defaults |
---|---|---|---|
var | It contains parsed XML data variables | no | no |
xml | Need to parse the text of the document content (String or Reader) | no | Body |
systemId | System identifier URI, is used to parse the document | no | no |
filter | Filters used in the source document | no | no |
doc | Need to parse XML documents | no | Page |
scope | Scope var attribute | no | Page |
varDom | It contains parsed XML data variables | no | Page |
scopeDom | Scope varDom property | no | Page |
Examples Demo
He took the case to tell us how to parse an XML document:
books.xml file code is as follows:
<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 file code is as follows:
<%@ 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>
Results are as follows:
BOOKS INFO: The title of the first book is:Padam History The price of the second book: 2000