gpt4 book ai didi

html - 在现有 HTML/CSS 模板中嵌入 XML 数据

转载 作者:太空宇宙 更新时间:2023-11-03 17:48:23 24 4
gpt4 key购买 nike

我想将 XML 文件嵌入到我创建的现有模板中。我的网站包含内容标题、内容部分、侧边栏等。但我想将 XML 数据嵌入到内容部分,这样我就可以使用现有的 CSS 和格式,而无需在 XSLT 中重写一半。我已经遇到过“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。

最佳答案

HTML 4 和 HTML5 都没有 xml 元素,只有 Windows 上的旧版 IE 支持在 HTML 中内嵌所谓的 XML 数据岛。因此,除了嵌入其他内容(即 iframe 元素和 object 元素)之外,没有其他方法可以将外部 XML 文档嵌入到 HTML 文档中。就静态 HTML 而言,当然如果你有一些服务器端编程/处理框架或者想依赖客户端脚本,那么还有其他选择。

关于html - 在现有 HTML/CSS 模板中嵌入 XML 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27781214/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com