Latest web development tutorials

<X: parsen> -Tag

JSP Standard-Tag-Bibliothek JSP Standard - Tag - Bibliothek

<X: parsen> -Tag wird verwendet, um Eigenschaftstag Körper oder XML-Daten lösen.

Syntax

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

Immobilien

<X: Analysieren> Tag hat folgende Attribute:

Immobilien Beschreibung notfalls Default
var Es enthält analysierten XML-Datenvariablen keine keine
xml Benötigen Sie den Text des Dokumentinhalts (String oder Reader) zu analysieren, keine Körper
systemId System Identifier URI, wird verwendet, um das Dokument zu parsen keine keine
Filter Filter in dem Quelldokument verwendet keine keine
doc Benötigen Sie XML-Dokumente zu analysieren keine Seite
Anwendungsbereich Scope var Attribut keine Seite
varDom Es enthält analysierten XML-Datenvariablen keine Seite
scopeDom Scope varDom Eigenschaft keine Seite


Beispiele Demo

Er nahm den Fall, uns zu sagen, wie ein XML-Dokument zu analysieren:

books.xml Datei Code ist wie folgt:

<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 Datei Code ist wie folgt:

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

Ergebnisse sind wie folgt:

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

JSP Standard-Tag-Bibliothek JSP Standard - Tag - Bibliothek