x_out.jsp

来自「jsp入门级代码」· JSP 代码 · 共 55 行

JSP
55
字号
<%@ page contentType="text/html;charset=GBK"%>
<%@ 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: XML -- Parse / Out</title>
</head>
<body>
<h3>parse和out标签的实例</h3>
<c:import var="docString" url="games.xml"/><!--引入games.xml文件-->
<x:parse var="doc" doc="${docString}"/>
<table border=1>
  <tr>
    <td valign="top"><pre><c:out value="${docString}"/></pre></td>
    <td valign="top">
      <table border=1>
        <tr>
          <th>XPath表达式</th>
          <th>查找到的元素</th>
        </tr>
        <tr>
          <td>$doc//sport</td>
          <td><pre><x:out select="$doc//sport"/></pre></td>
        </tr>
        <tr>
          <td>$doc/games/country/*</td>
          <td><pre><x:out select="$doc/games/country/*"/></pre></td>
        </tr>
        <tr>
          <td>$doc//*</td>
          <td><pre><x:out select="$doc//*"/></pre></td>
        </tr>
        <tr>
          <td>$doc/games/country</td>
          <td><pre><x:out select="$doc/games/country"/></pre></td>
        </tr>
        <tr>
          <td>$doc/games/country[last()]</td>
          <td><pre><x:out select="$doc/games/country[last()]"/></pre></td>
        </tr>
        <tr>
          <td>$doc//@id</td>
          <td><pre><x:out select="$doc//@id"/></pre></td>
        </tr>
        <tr>
          <td>$doc//country[@id='Denmark']</td>
          <td><pre><x:out select="$doc//country[@id='Denmark']"/></pre></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?