\u5728JSP\u4e2d\u5904\u7406XML<\/strong><\/div>\n\u5728\u4f7f\u7528JSP\u5904\u7406XML\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u5c06\u4e0eXML \u548cXPath\u76f8\u5173\u7684\u4e24\u4e2a\u5e93\u6587\u4ef6\u653e\u5728<Tomcat Installation Directory>\\lib\u76ee\u5f55\u4e0b\uff1a<\/p>\n
books.xml\u6587\u4ef6:<\/p>\n
\r\n<books>\r\n<book>\r\n <name>Padam History<\/name>\r\n <author>ZARA<\/author>\r\n <price>100<\/price>\r\n<\/book>\r\n<book>\r\n <name>Great Mistry<\/name>\r\n <author>NUHA<\/author>\r\n <price>2000<\/price>\r\n<\/book>\r\n<\/books><\/pre>\nmain.jsp\u6587\u4ef6\uff1a<\/p>\n
\r\n<%@ page language=\"java\" contentType=\"text\/html; charset=UTF-8\"\r\n pageEncoding=\"UTF-8\"%>\r\n<%@ taglib prefix=\"c\" uri=\"http:\/\/java.sun.com\/jsp\/jstl\/core\" %>\r\n<%@ taglib prefix=\"x\" uri=\"http:\/\/java.sun.com\/jsp\/jstl\/xml\" %>\r\n \r\n<html>\r\n<head>\r\n <title>JSTL x:parse Tags<\/title>\r\n<\/head>\r\n<body>\r\n<h3>Books Info:<\/h3>\r\n<c:import var=\"bookInfo\" url=\"http:\/\/localhost:8080\/books.xml\"\/>\r\n \r\n<x:parse xml=\"${bookInfo}\" var=\"output\"\/>\r\n<b>The title of the first book is<\/b>: \r\n<x:out select=\"$output\/books\/book[1]\/name\" \/>\r\n<br>\r\n<b>The price of the second book<\/b>: \r\n<x:out select=\"$output\/books\/book[2]\/price\" \/>\r\n \r\n<\/body>\r\n<\/html><\/pre>\n\u8bbf\u95eehttp:\/\/localhost:8080\/main.jsp\uff0c\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n
\r\nBOOKS INFO:\r\nThe title of the first book is:Padam History \r\nThe price of the second book: 2000<\/pre>\n\u4f7f\u7528JSP\u683c\u5f0f\u5316XML<\/strong><\/div>\n\u8fd9\u4e2a\u662fXSLT\u6837\u5f0f\u8868style.xsl\u6587\u4ef6\uff1a<\/p>\n
\r\n<?xml version=\"1.0\"?>\r\n<xsl:stylesheet xmlns:xsl=\r\n\"http:\/\/www.w3.org\/1999\/XSL\/Transform\" version=\"1.0\">\r\n \r\n<xsl:output method=\"html\" indent=\"yes\"\/>\r\n \r\n<xsl:template match=\"\/\">\r\n <html>\r\n <body>\r\n <xsl:apply-templates\/>\r\n <\/body>\r\n <\/html>\r\n<\/xsl:template>\r\n \r\n<xsl:template match=\"books\">\r\n <table border=\"1\" width=\"100%\">\r\n <xsl:for-each select=\"book\">\r\n <tr>\r\n <td>\r\n <i><xsl:value-of select=\"name\"\/><\/i>\r\n <\/td>\r\n <td>\r\n <xsl:value-of select=\"author\"\/>\r\n <\/td>\r\n <td>\r\n <xsl:value-of select=\"price\"\/>\r\n <\/td>\r\n <\/tr>\r\n <\/xsl:for-each>\r\n <\/table>\r\n<\/xsl:template>\r\n<\/xsl:stylesheet><\/pre>\n\u8fd9\u4e2a\u662fmain.jsp\u6587\u4ef6\uff1a<\/p>\n
\r\n<%@ taglib prefix=\"c\" uri=\"http:\/\/java.sun.com\/jsp\/jstl\/core\" %>\r\n<%@ taglib prefix=\"x\" uri=\"http:\/\/java.sun.com\/jsp\/jstl\/xml\" %>\r\n \r\n<html>\r\n<head>\r\n <title>JSTL x:transform Tags<\/title>\r\n<\/head>\r\n<body>\r\n<h3>Books Info:<\/h3>\r\n<c:set var=\"xmltext\">\r\n <books>\r\n <book>\r\n <name>Padam History<\/name>\r\n <author>ZARA<\/author>\r\n <price>100<\/price>\r\n <\/book>\r\n <book>\r\n <name>Great Mistry<\/name>\r\n <author>NUHA<\/author>\r\n <price>2000<\/price>\r\n <\/book>\r\n <\/books>\r\n<\/c:set>\r\n \r\n<c:import url=\"http:\/\/localhost:8080\/style.xsl\" var=\"xslt\"\/>\r\n<x:transform xml=\"${xmltext}\" xslt=\"${xslt}\"\/>\r\n \r\n<\/body>\r\n<\/html>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"\u5f53\u901a\u8fc7HTTP\u53d1\u9001XML\u6570\u636e\u65f6\uff0c\u5c31\u6709\u5fc5\u8981\u4f7f\u7528JSP\u6765\u5904\u7406\u4f20\u5165\u548c\u6d41\u51fa\u7684XML\u6587\u6863\u4e86\uff0c\u6bd4\u5982RSS\u6587\u6863\u3002\u4f5c\u4e3a\u4e00\u4e2aXM […]<\/p>\n","protected":false},"author":321,"featured_media":223365,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-223437","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/223437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/321"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=223437"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/223437\/revisions"}],"predecessor-version":[{"id":223442,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/223437\/revisions\/223442"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/223365"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=223437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=223437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=223437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}