Latest web development tutorials

<X: analizzare> tag

Biblioteca JSP Standard Tag Biblioteca JSP Standard Tag

<X: analizzare> tag viene utilizzato per risolvere i dati proprietà Body tag o XML.

sintassi

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

proprietà

<X: analizzare> tag ha i seguenti attributi:

proprietà descrizione Se necessario difetto
var Esso contiene variabili di dati XML analizzato no no
xml Necessità di analizzare il testo del contenuto del documento (String o Reader) no corpo
systemId identificatore di sistema URI, viene utilizzato per analizzare il documento no no
filtro I filtri utilizzati nel documento di origine no no
doc Necessità di analizzare i documenti XML no pagina
portata attributo var Scope no pagina
varDom Esso contiene variabili di dati XML analizzato no pagina
scopeDom Ambito beni varDom no pagina


Esempi Demo

Ha preso il caso di dirci come analizzare un documento XML:

codice del file Books.xml è il seguente:

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

codice del file main.jsp è il seguente:

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

I risultati sono i seguenti:

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

Biblioteca JSP Standard Tag Biblioteca JSP Standard Tag