簡體   English   中英

在HTML中顯示XML,僅適用於ie6

[英]Showing XML in HTML, works only in ie6

此代碼僅適用於IE6,為什么會這樣? 以及如何在html中顯示我的xml(沒有css)?

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<xml id="xmlcatalog" src="catalog.xml"> 
</xml>
<table datasrc = "#xmlcatalog" width="100%">
    <thead>
      <th>Image</th>
      <th>Date</th>
      <th>Time</th>
      <th>Title</th>
      <th>Author</th>
      <th>Genre</th>
    </thead>
    <tr align="left">
        <td><span datafld="image"></span></td>
        <td><span datafld="date"></span></td>
        <td><span datafld="time"></span></td>
        <td><span datafld="title"></span></td>
        <td><span datafld="author"></span></td>
        <td><span datafld="genre"></span></td>         
    </tr>
</table>
</body>
</html>

XML

<?xml version="1.0" encoding="windows-1251"?>
<catalog>
 <spectacle>
   <image>Lir.gif</image>
   <date> 16.09.10</date>
   <time> 19:00</time>
   <title> King Lear</title>
   <author> William Shakespeare/author>
   <genre>  tragedy </genre>
 </spectacle>
</catalog>

* 更新: *還存在使用XSLT的解決方案http://www.w3schools.com/xsl/xsl_for_each.asp

此代碼僅適用於IE6,為什么會這樣?

因為它是非標准的專有代碼。

以及如何在html中顯示我的xml(沒有css)?

使用編程語言將數據轉換為HTML並將其插入到文檔中。 如果您想要最佳兼容性和搜索引擎友好性,請在服務器端進行。

這是IE專有代碼,不屬於任何HTML規范。 如果要導入XML,則必須使用服務器端腳本,或者最糟糕的是,使用Javascript。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM