小白教程
所有教程
关于
Search
172.70.127.153
172.70.127.153
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Jstl xml parse tag”的源代码
本页内容
上一节:
Jstl_xml_out_tag
下一节:
Jstl_xml_set_tag
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:<x:parse>}}[[Category:jsp jstl|33]] = <x:parse> 标签 = [[jsp jstl|JSP 标准标签库]] <x:parse>标签用来解析属性中或标签主体中的XML数据。 === 语法格式 === <sample title="" desc="" lang="jsp" hererun="1"> <x:parse var="<string>" varDom="<string>" scope="<string>" scopeDom="<string>" doc="<string>" systemId="<string>" filter="<string>"/> </sample> === 属性 === <x:parse>标签有如下属性: {| class="table table-striped table-hover" ! '''属性''' ! '''描述''' ! '''是否必要''' ! '''默认值''' |- | var | 包含已解析XML数据的变量 | 否 | 无 |- | xml | 需要解析的文档的文本内容(String或Reader) | 否 | Body |- | systemId | 系统标识符URI,用来解析文档 | 否 | 无 |- | filter | 应用于源文档的过滤器 | 否 | 无 |- | doc | 需要解析的XML文档 | 否 | Page |- | scope | var属性的作用域 | 否 | Page |- | varDom | 包含已解析XML数据的变量 | 否 | Page |- | scopeDom | varDom属性的作用域 | 否 | Page |} == 实例演示 == 接下了的例子告诉我们如何解析一个XML文档: books.xml文件代码如下: <sample title="" desc="" lang="jsp" hererun="1"> <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> </sample> main.jsp文件代码如下: <sample title="" desc="" lang="jsp" hererun="1"> <%@ 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> </sample> 运行结果如下: <sample title="" desc="" lang="jsp" hererun="1"> BOOKS INFO: The title of the first book is:Padam History The price of the second book: 2000 </sample> [[jsp jstl|JSP 标准标签库]]
返回至“
Jstl xml parse tag
”。
上一节:
Jstl_xml_out_tag
下一节:
Jstl_xml_set_tag