我想将XML文件嵌入到我正在创建的现有模板中。我的网站包含内容标题,内容部分,侧边栏等。但我想将XML数据嵌入到内容部分,这样我就可以使用现有的CSS和格式,而无需在XSLT中重写一半。我已经遇到了#34; xml"标记,但我想从外部文件而不是内联中导入它。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Local fish and chips bar, serving the city for over 20 years.">
<meta name="keywords" content="Food,Drink,Fish,Chips,British">
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
<div id="header">
<h1>
<img alt="logo" src="images\logo.jpg" style="width:473px;height:135px">Home</h1>
</div>
<div id = "wrap">
<div id = "navWrap">
<div id = "nav">
<ul>
<li><a class ="nav" href="index.html">Home</a></li>
<li><a class ="nav" href="order.html">Order Online</a></li>
<li><a class ="nav" href="look.html">Look Around</a></li>
<li><a class ="nav" href="contact.html">Contact Us</a></li>
<li><a class ="nav" href="#menu">Download Our Menu</a></li>
<li><a class ="nav" href="#contact">Download Our App</a></li>
<li><a class ="nav" href="report.html">Report</a></li>
</ul>
</div>
</div>
</div>
<div id="main">
<xml Id = msg SRC = "menu.xml"></xml> ----- **XML GOES HERE**
</div>
<div id="sidebar">
<div id = "sidebarMain">
</div>
<div id = "mapWrap">
<iframe src= width="400" height="300" frameborder="0" style="border:0"></iframe>
</div>
<h3><center><u>Opening Times</u></center></h3>
<table style="width:100%">
<tr>
<th>Day</th>
<th>Lunch</th>
<th>Evening</th>
</tr>
<tr>
<td>Monday</td>
<td>10:00 - 14:00</td>
<td>16:00 - 22:00</td>
</tr>
<tr>
<td>Tuesday</td>
<td>10:00 - 14:00</td>
<td>16:00 - 22:00</td>
</tr>
<tr>
<td>Wednesday</td>
<td>10:00 - 14:00</td>
<td>16:00 - 22:00</td>
</tr>
<tr>
<td>Thursday</td>
<td>10:00 - 14:00</td>
<td>16:00 - 22:00</td>
</tr>
<tr>
<td>Friday</td>
<td>10:00 - 14:00</td>
<td>15:00 - 23:00</td>
</tr>
<tr>
<td>Saturday</td>
<td>10:00 - 14:00</td>
<td>15:00 - 23:00</td>
</tr>
<tr>
<td>Sunday</td>
<td>Closed</td>
<td>Closed</td>
</tr>
</table>
</div>
<div id = "footer">
Copyright © FryingNemo.com<br>
<br>
</div>
</body>
</head>
我的xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="nemoMenu.xsl"?>
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>Two of our famous Belgian Waffles with plenty of real maple syrup</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>Light Belgian waffles covered with strawberries and whipped cream</description>
<calories>900</calories>
</food>
<food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>Light Belgian waffles covered with an assortment of fresh berries and whipped cream</description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<description>Thick slices made from our homemade sourdough bread</description>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>Two eggs, bacon or sausage, toast, and our ever-popular hash browns</description>
<calories>950</calories>
</food>
</breakfast_menu>
关于这个问题的任何决议都会受到赞赏,或者我可能只是简单地使用XSLT。
答案 0 :(得分:0)
HTML 4和HTML5都没有xml
元素,只有Windows上的旧版IE支持在HTML中嵌入所谓的XML data islands
内联。因此,除了嵌入其他内容,即iframe
元素和object
元素之外,没有其他方法可以将外部XML文档嵌入到HTML文档中。就静态HTML而言,当然如果你有一些服务器端编程/处理框架或者想要依赖客户端脚本,那么还有其他选择。