English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Bibliothèque de balises standard JSP
Le tag <x:parse> est utilisé pour interpréter les données XML dans les attributs ou le corps des tags.
<x:parse var="<string>" varDom="<string>" scope="<string>" scopeDom="<string>" doc="<string>" systemId="<string>" filter="<string>"/>
Les attributs du tag <x:parse> sont les suivants:
Attribut | Description | Est-ce nécessaire | Valeur par défaut |
---|---|---|---|
var | Variable contenant les données XML interprétées | Non | Aucun |
xml | Contenu texte du document à interpréter (String ou Reader) | Non | Body |
systemId | Identifiant système URI, utilisé pour interpréter le document | Non | Aucun |
filter | Filtre appliqué au document source | Non | Aucun |
doc | Document XML à interpréter | Non | Page |
scope | L'portée de l'attribut var | Non | Page |
varDom | Variable contenant les données XML interprétées | Non | Page |
scopeDom | L'portée de l'attribut varDom | Non | Page |
L'exemple suivant nous montre comment解析 un document XML:
Le code du fichier books.xml est le suivant:
<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>
Le code du fichier main.jsp est le suivant:
<%@ 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 Tag</title> </head> <body> <h2>Infos Livres :</h2> <c:import var="bookInfo" url="http://localhost:8080/books.xml"/> <x:parse xml="${bookInfo}" var="output"/> <b>Le titre du premier livre est</b> : <x:out select="$output/books/book[1]/name" /> <br> <b>Le prix du deuxième livre</b> : <x:out select="$output/books/book[2]/price" /> </body> </html>
Résultat de l'exécution ci-dessous :
INFOS LIVRES : Le titre du premier livre est : Histoire de Padam Le prix du deuxième livre : 2000