[英]How to output XML in HTML format
我有一个正在尝试自定义的项目。 我正在尝试使用HTML创建商店定位器应用程序,并调用一个URL以XML格式输出数据。
我使用的输入表单接受参数:
<!DOCTYPE html>
<html>
<head>
<title>Store Locator</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<div align="center">
<form action="SmartHomePage2.html" method="post">
<table cellspacing="5">
<tr>
<td colspan="2" align="center">
<h2>Store Locator</h2>
</td>
</tr>
<tr>
<td align="right">
Enter Your Zip Code:
</td>
<td>
<input type="text" name="zip" value="" />
</td>
</tr>
<tr>
<td align="right">
Enter the search radius in miles:
</td>
<td>
<input type="text" name="dist" value="" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Search" />
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
这是我的输出页面的样子:
<!DOCTYPE html>
<html>
<head>
<title>Search Results</title>
</head>
<body>
<h1>Best Buy Results</h1>
<c:import url="http://api.remix.bestbuy.com/v1/stores(area
(${param.zip},${param.dist}))?show=storeId,name,distance,lat,lng
&apiKey=ruuk8c4ux2p4e7d6bfftzuda" var="message" />
<x:parse var="a" doc="${message}" />
<x:forEach var="current" select="$a/stores/store">
<b> Store ID: </b> <x:out select="$current/storeId" />
<br />
<b> Name: </b> <x:out select="$current/name" />
<br />
<b> Distance: </b> <x:out select="$current/distance" />
<br />
<b> Latitude: </b> <x:out select="$current/lat" />
<br />
<b> Longitude: </b> <x:out select="$current/lng" />
<br />
</li>
</ul>
</x:forEach>
</body>
</html>
我的问题是如何用HTML输出XML数据? 还是我需要合并一些JavaScript?
先感谢您。
您可以使用XSL做到这一点,这是一个很好的解释和示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.