Latest web development tutorials

<X: analizar> etiqueta

JSP Standard Tag Library JSP Standard Tag Library

<X: analizar> se utiliza para resolver datos del cuerpo etiqueta de propiedad o XML.

sintaxis

<x:parse
  var="<string>"
  varDom="<string>"
  scope="<string>"
  scopeDom="<string>"
  doc="<string>"
  systemId="<string>"
  filter="<string>"/>

propiedad

<X: analizar> tiene los siguientes atributos:

propiedad descripción Si es necesario defecto
var Contiene las variables de datos XML analizado no no
xml La necesidad de analizar el texto del contenido del documento (String o Reader) no cuerpo
systemId identificador del sistema URI, se utiliza para analizar el documento no no
filtro Los filtros usados ​​en el documento fuente no no
doctor Necesidad de analizar documentos XML no página
alcance atributo var alcance no página
varDom Contiene las variables de datos XML analizado no página
scopeDom Ámbito propiedad varDom no página


Los ejemplos de demostración

Tomó el caso que nos diga cómo analizar un documento XML:

código del archivo books.xml es el siguiente:

<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ódigo de archivo main.jsp es el siguiente:

<%@ 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>

Los resultados son como sigue:

BOOKS INFO:
The title of the first book is:Padam History 
The price of the second book: 2000

JSP Standard Tag Library JSP Standard Tag Library